Class: Easydsl::NodeBuilder
- Inherits:
-
Object
- Object
- Easydsl::NodeBuilder
- Defined in:
- lib/easydsl/node_builder.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, *args) ⇒ NodeBuilder
constructor
A new instance of NodeBuilder.
- #method_missing(method_symbol, *args, &block) ⇒ Object
- #nodes ⇒ Object
Constructor Details
#initialize(name, *args) ⇒ NodeBuilder
Returns a new instance of NodeBuilder.
9 10 11 12 |
# File 'lib/easydsl/node_builder.rb', line 9 def initialize(name, *args) @name = name @args = args end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_symbol, *args, &block) ⇒ Object
14 15 16 17 18 |
# File 'lib/easydsl/node_builder.rb', line 14 def method_missing(method_symbol, *args, &block) child = NodeBuilder.new(method_symbol, *args) nodes.push(child) child.instance_exec(&block) if block_given? end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
3 4 5 |
# File 'lib/easydsl/node_builder.rb', line 3 def args @args end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/easydsl/node_builder.rb', line 3 def name @name end |
Instance Method Details
#nodes ⇒ Object
5 6 7 |
# File 'lib/easydsl/node_builder.rb', line 5 def nodes @nodes ||= [] end |