Module: RAML::EvalParser::MethodMissing

Defined in:
lib/raml/eval_parser.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/raml/eval_parser.rb', line 124

def method_missing(name, *args, &block)
  return @__data__[name] if args.empty? and !block
  if block
    val = EvalParser.new(@__parser__.options).parse(&block)
  else
    val = args.size == 1 ? args.first : args
  end
  if @__parser__.multi_key?
    if @__data__.key?(name)
      unless MultiValue === @__data__[name]
        @__data__[name] = MultiValue.new(@__data__[name])
      end
      @__data__[name] << val
    else
      @__data__[name] = val
    end
  else
    @__data__[name] = val
    val
  end
end