Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/distorted/monkey_business/hash.rb

Instance Method Summary collapse

Instance Method Details

#bury(*args) ⇒ Object

github.com/dam13n/ruby-bury/blob/master/hash.rb This is not packaged as a Gem or I’d be using it instead of including my own.



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/distorted/monkey_business/hash.rb', line 20

def bury(*args)
  if args.count < 2
    raise ArgumentError.new('2 or more arguments required')
  elsif args.count == 2
    self[args[0]] = args[1]
  else
    arg = args.shift
    self[arg] = {} unless self[arg]
    self[arg].bury(*args) unless args.empty?
  end
  self
end