Class: SimpleFactory::DSL
- Inherits:
-
Object
- Object
- SimpleFactory::DSL
- Defined in:
- lib/simple_factory/dsl.rb
Instance Attribute Summary collapse
-
#definitions ⇒ Object
readonly
Returns the value of attribute definitions.
Instance Method Summary collapse
-
#initialize ⇒ DSL
constructor
A new instance of DSL.
- #method_missing(name, *args, &block) ⇒ Object
Constructor Details
#initialize ⇒ DSL
Returns a new instance of DSL.
7 8 9 |
# File 'lib/simple_factory/dsl.rb', line 7 def initialize @definitions = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/simple_factory/dsl.rb', line 11 def method_missing(name, *args, &block) unless args.size >= 1 || block raise ArgumentError, 'an argument or a block is required' end @definitions << Definition.new(name, (args.size >= 1 ? args.first : block)) end |
Instance Attribute Details
#definitions ⇒ Object (readonly)
Returns the value of attribute definitions.
5 6 7 |
# File 'lib/simple_factory/dsl.rb', line 5 def definitions @definitions end |