class Hash

Constants

METHOD_SPLITTER

Public Instance Methods

method_missing(method_name, *args) click to toggle source
# 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

Private Instance Methods

split_name_and_suffix(method_name) click to toggle source
# File lib/jr/cli/core_ext/hash.rb, line 18
def split_name_and_suffix(method_name)
  match = method_name.to_s.match(METHOD_SPLITTER)
  [match[1], match[2]]
end