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.
50 51 52 53 |
# File 'lib/modelfactory.rb', line 50 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.
56 57 58 59 |
# File 'lib/modelfactory.rb', line 56 def method_missing(method, klass, &block) @class_opts[klass] ||= {} @class_opts[klass][method] = block end |
Instance Attribute Details
#class_opts ⇒ Object (readonly)
:nodoc:
48 49 50 |
# File 'lib/modelfactory.rb', line 48 def class_opts @class_opts end |