Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/ioc_rb/inject.rb
Overview
Extend object with the bean injection mechanism Example of usage: class Bar end
class Foo
inject :bar
or:
inject :some_bar, ref: bar
end
ioc_container.bar == ioc_container
Class Method Summary collapse
Class Method Details
.inject(dependency_name, options = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ioc_rb/inject.rb', line 17 def inject(dependency_name, = {}) unless dependency_name.is_a?(Symbol) raise ArgumentError, "dependency name should be a symbol" end unless .is_a?(Hash) raise ArgumentError, "second argument for inject method should be a Hash" end unless respond_to?(:_iocrb_injectable_attrs) class_attribute :_iocrb_injectable_attrs self._iocrb_injectable_attrs = { dependency_name => .dup } else self._iocrb_injectable_attrs = self._iocrb_injectable_attrs.merge(dependency_name => .dup) end attr_accessor dependency_name end |