Class: Orchparty::CommonBuilder

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

Direct Known Subclasses

AllBuilder, ServiceBuilder

Instance Method Summary collapse

Constructor Details

#initializeCommonBuilder

Returns a new instance of CommonBuilder.



155
156
157
# File 'lib/orchparty/dsl_parser.rb', line 155

def initialize
  @service = AST::Service.new(_mix: [])
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



163
164
165
166
167
168
169
170
171
# File 'lib/orchparty/dsl_parser.rb', line 163

def method_missing(name, *values, &block)
  if block_given?
    builder = HashBuilder.new
    builder.instance_eval(&block)
    @service[name] = builder._build
  else
    @service[name] = values.first
  end
end

Instance Method Details

#_buildObject



173
174
175
# File 'lib/orchparty/dsl_parser.rb', line 173

def _build
  @service
end

#mix(name) ⇒ Object



159
160
161
# File 'lib/orchparty/dsl_parser.rb', line 159

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

#variables(&block) ⇒ Object



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

def variables(&block)
  builder  = HashBuilder.new
  builder.instance_eval(&block)
  @service._variables = builder._build
  self
end