Class: Dimr::Factory
- Inherits:
-
Object
- Object
- Dimr::Factory
- Defined in:
- lib/dimr.rb
Instance Method Summary collapse
- #call(*args) ⇒ Object
-
#initialize(klass, dependencies) ⇒ Factory
constructor
A new instance of Factory.
Constructor Details
#initialize(klass, dependencies) ⇒ Factory
Returns a new instance of Factory.
27 28 29 |
# File 'lib/dimr.rb', line 27 def initialize(klass, dependencies) @klass, @dependencies = klass, dependencies end |
Instance Method Details
#call(*args) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/dimr.rb', line 31 def call(*args) instance = @klass.new(*args) @dependencies.each do |key, value| instance.send("#{key}=", value) end if @dependencies instance end |