Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/wlang/ext/hash_methodize.rb

Instance Method Summary (collapse)

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(name, *args, &block)

Allows using hash.key as a synonym for hash and hash



5
6
7
8
9
10
11
# File 'lib/wlang/ext/hash_methodize.rb', line 5

def method_missing(name, *args, &block)
  if args.empty? and block.nil?
    self[name] || self[name.to_s]
  else
    super(name, *args, &block)
  end
end