Dependancy
Getters & setters for dependency injection
Installation
Add this line to your application's Gemfile:
gem 'dependancy'
And then execute:
$ bundle
Or install it yourself as:
$ gem install dependancy
Usage
class Bar
attr_accessor :name
end
class Foo
extend Dependancy
def name
'foo name'
end
dependancy :bar1 do
Bar.new
end
dependancy :bar2 do |foo|
= Bar.new
.name = foo.name
end
dependancy :bar3
end
Foo._dependancies == [:bar1, :bar2, :bar3] # true
foo = Foo.new
foo..is_a? Bar # true
foo..is_a? Bar # true
foo..name == foo.name # true
= Bar.new
foo = Foo.bild bar:
foo. == # true
foo = Dependancy::Bild.bild Foo, bar:
foo. == # true
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Added some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
