Method: Hash#method_missing

Defined in:
lib/rmtools/core/js.rb

#method_missing(method, *args) ⇒ Object

hash = {} hash.abc = 123 hash # => “abc”=>123 hash.abc # => 123 hash.unknown_function(321) # => raise NoMethodError hash.unknown_function # => nil hash = 456 hash.def # => 456

This priority should be stable, because



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rmtools/core/js.rb', line 16

def method_missing(method, *args)
  str = method.to_s
  if str =~ /=$/
    self[str[0..-2]] = args[0]
  elsif !args.empty? or str =~ /[!?]$/
    super
  else
    a = self[method]
    (a == default) ? self[str] : a
  end
end