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.



147
148
149
# File 'lib/orchparty/dsl_parser.rb', line 147

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



155
156
157
158
159
160
161
162
163
# File 'lib/orchparty/dsl_parser.rb', line 155

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



165
166
167
# File 'lib/orchparty/dsl_parser.rb', line 165

def _build
  @service
end

#mix(name) ⇒ Object



151
152
153
# File 'lib/orchparty/dsl_parser.rb', line 151

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

#variables(&block) ⇒ Object



169
170
171
172
173
174
# File 'lib/orchparty/dsl_parser.rb', line 169

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