Module: Bury
- Defined in:
- lib/abstract-synthesizer/primitives/bury.rb
Class Method Summary collapse
Class Method Details
.add_bury_to_hash ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/abstract-synthesizer/primitives/bury.rb', line 3 def add_bury_to_hash Hash.send(:define_method, :bury) do |*args| # arg 0 is key arg 1 is val if args.count < 2 raise ArgumentError, %(2 or more arguments required) elsif args.count == 2 self[args[0]] = args[1] # if we have more args bury the arg recursively else arg = args.shift self[arg] = {} unless self[arg] self[arg].bury(*args) unless args.empty? end end end |