Class: Easydsl::NodeBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/easydsl/node_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#argsObject (readonly)

Returns the value of attribute args.



3
4
5
# File 'lib/easydsl/node_builder.rb', line 3

def args
  @args
end

#nameObject (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

#nodesObject



5
6
7
# File 'lib/easydsl/node_builder.rb', line 5

def nodes
  @nodes ||= []
end