Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/jr/cli/core_ext/hash.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/jr/cli/core_ext/hash.rb', line 2

def method_missing(method_name, *args)
  return self[method_name] if key? method_name
  name, suffix = split_name_and_suffix(method_name)
  case suffix
  when '?'
    !!self[name.to_sym]
  when '='
    self[name.to_sym] = args[0]
  else
    self[name.to_sym]
  end
end