Class: Orchparty::CommonBuilder

Inherits:
Builder
  • Object
show all
Defined in:
lib/orchparty/dsl_parser.rb

Instance Method Summary collapse

Methods inherited from Builder

#assign_or_merge, build

Constructor Details

#initialize(node) ⇒ CommonBuilder

Returns a new instance of CommonBuilder.



176
177
178
# File 'lib/orchparty/dsl_parser.rb', line 176

def initialize(node)
  @node = node
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *values, &block) ⇒ Object



184
185
186
187
188
189
190
# File 'lib/orchparty/dsl_parser.rb', line 184

def method_missing(name, *values, &block)
  if block_given?
    assign_or_merge(@node, name,  HashBuilder.build(block))
  else
    assign_or_merge(@node, name, values.first)
  end
end

Instance Method Details

#_buildObject



192
193
194
# File 'lib/orchparty/dsl_parser.rb', line 192

def _build
  @node
end

#mix(name) ⇒ Object



180
181
182
# File 'lib/orchparty/dsl_parser.rb', line 180

def mix(name)
  @node._mix << name
end

#variables(&block) ⇒ Object



196
197
198
199
200
# File 'lib/orchparty/dsl_parser.rb', line 196

def variables(&block)
  @node._variables ||= {}
  @node._variables = @node._variables.merge(VariableBuilder.build(block))
  self
end