Class: ActionFactory::Runner
- Inherits:
-
Object
- Object
- ActionFactory::Runner
- Defined in:
- lib/action_factory/runner.rb
Instance Attribute Summary collapse
-
#factory ⇒ Object
readonly
Returns the value of attribute factory.
-
#factory_name ⇒ Object
readonly
Returns the value of attribute factory_name.
-
#strategy ⇒ Object
readonly
Returns the value of attribute strategy.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(factory_name, *traits, strategy: nil, **attributes) ⇒ Runner
constructor
A new instance of Runner.
- #run(strategy = nil) ⇒ Object
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
#factory ⇒ Object (readonly)
Returns the value of attribute factory.
15 16 17 |
# File 'lib/action_factory/runner.rb', line 15 def factory @factory end |
#factory_name ⇒ Object (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 |
#strategy ⇒ Object (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
.run ⇒ Object
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 |