Class: Easydsl::NodeBuilder

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

Instance Method Summary collapse

Constructor Details

#initialize(name, *args) ⇒ NodeBuilder

Returns a new instance of NodeBuilder.



15
16
17
18
# File 'lib/easydsl/node_builder.rb', line 15

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



20
21
22
23
24
# File 'lib/easydsl/node_builder.rb', line 20

def method_missing(method_symbol, *args, &block)
  child = NodeBuilder.new(method_symbol, *args)
  get_nodes.push(child)
  child.instance_exec(&block) if block_given?
end

Instance Method Details

#get_argsObject



11
12
13
# File 'lib/easydsl/node_builder.rb', line 11

def get_args
  @args
end

#get_nameObject



7
8
9
# File 'lib/easydsl/node_builder.rb', line 7

def get_name
  @name
end

#get_nodesObject



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

def get_nodes
  @nodes ||= []
end