Class: ModelFactory::FactoryConfiguration
- Inherits:
-
Object
- Object
- ModelFactory::FactoryConfiguration
- Defined in:
- lib/modelfactory.rb
Overview
Factory configuration class.
Instance Attribute Summary collapse
-
#class_opts ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
-
#initialize(&block) ⇒ FactoryConfiguration
constructor
A new instance of FactoryConfiguration.
-
#method_missing(method, klass, &block) ⇒ Object
All method calls set up a configuration named after the method.
Constructor Details
#initialize(&block) ⇒ FactoryConfiguration
Returns a new instance of FactoryConfiguration.
54 55 56 57 |
# File 'lib/modelfactory.rb', line 54 def initialize(&block) @class_opts = {} instance_eval(&block) if block_given? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, klass, &block) ⇒ Object
All method calls set up a configuration named after the method.
60 61 62 63 |
# File 'lib/modelfactory.rb', line 60 def method_missing(method, klass, &block) @class_opts[klass] ||= {} @class_opts[klass][method] = block end |
Instance Attribute Details
#class_opts ⇒ Object (readonly)
:nodoc:
52 53 54 |
# File 'lib/modelfactory.rb', line 52 def class_opts @class_opts end |