Class: Orchparty::HashBuilder
Instance Method Summary
collapse
Methods inherited from Builder
#assign_or_merge, build
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(_, *values, &block) ⇒ Object
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
# File 'lib/orchparty/dsl_parser.rb', line 145
def method_missing(_, *values, &block)
if block_given?
value = HashBuilder.build(block)
if values.count == 1
@hash ||= AST.hash
@hash[values.first.to_sym] = value
else
@hash ||= AST.array
@hash << value
end
else
value = values.first
if value.is_a? Hash
@hash ||= AST.hash
key, value = value.first
@hash[key.to_sym] = value
else
@hash ||= AST.array
@hash << value
end
end
self
end
|
Instance Method Details
#_build ⇒ Object
169
170
171
|
# File 'lib/orchparty/dsl_parser.rb', line 169
def _build
@hash
end
|