Class: Rubory::CreationDsl
- Inherits:
-
Object
- Object
- Rubory::CreationDsl
- Defined in:
- lib/factories.rb
Class Method Summary collapse
Instance Method Summary collapse
- #associate(factory_name) ⇒ Object
-
#initialize(factory, context) ⇒ CreationDsl
constructor
A new instance of CreationDsl.
- #method_missing(method, *args, &creation_block) ⇒ Object
Constructor Details
#initialize(factory, context) ⇒ CreationDsl
Returns a new instance of CreationDsl.
65 66 67 68 |
# File 'lib/factories.rb', line 65 def initialize(factory, context) @factory = factory @context = context end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &creation_block) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/factories.rb', line 74 def method_missing(method, *args, &creation_block) if block_given? @factory.value_for(method, &creation_block) else @factory.value_for(method) { args.first } end end |
Class Method Details
Instance Method Details
#associate(factory_name) ⇒ Object
81 82 83 |
# File 'lib/factories.rb', line 81 def associate(factory_name) @factory.value_for(factory_name) { @context.create(factory_name) } end |