Class: ActionFactory::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/action_factory/runner.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(factory_name, *traits, strategy: nil, **attributes) ⇒ Runner

Returns a new instance of Runner.



18
19
20
21
22
23
# File 'lib/action_factory/runner.rb', line 18

def initialize(factory_name, *traits, strategy: nil, **attributes)
  @factory_name = factory_name
  @strategy = strategy
  factory_class = FactoryFinder.factory_class_for(@factory_name)
  @factory = factory_class.new(*traits, **attributes)
end

Instance Attribute Details

#factoryObject (readonly)

Returns the value of attribute factory.



15
16
17
# File 'lib/action_factory/runner.rb', line 15

def factory
  @factory
end

#factory_nameObject (readonly)

Returns the value of attribute factory_name.



15
16
17
# File 'lib/action_factory/runner.rb', line 15

def factory_name
  @factory_name
end

#strategyObject (readonly)

Returns the value of attribute strategy.



15
16
17
# File 'lib/action_factory/runner.rb', line 15

def strategy
  @strategy
end

Class Method Details

.runObject



10
11
12
# File 'lib/action_factory/runner.rb', line 10

def run(...)
  new(...).run
end

Instance Method Details

#run(strategy = nil) ⇒ Object



25
26
27
# File 'lib/action_factory/runner.rb', line 25

def run(strategy = nil)
  @factory.run(strategy || @strategy)
end