Injectable
Simple and powerfull injection with automatic setters for initialized variables and dependencies.
Very usefull if you have a lot of collaborators and you need to pass objects to them, rather than doing it manually follow the convetion below.
Installation
Add this line to your application's Gemfile:
gem 'injectable_initializer'
And then execute:
$ bundle
Or install it yourself as:
$ gem install injectable_initializer
Usage
class SomeCollaboratorClass
def initialize(variable)
@variable = variable
end
attr_reader :variable
end
class DummyClass
include Injectable::Initializer
def initialize(variable, other_variable)
overwrites = {}
super(overwrites, variable, other_variable)
end
def defaults
{
other_class: SomeCollaboratorClass.new(variable),
some_class: SomeCollaboratorClass.new(other_variable),
naked_collaborator: Class.new
}
end
end
Contributing
- Fork it ( http://github.com/andrei-miulescu/injectable/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request