Class: Hash
Instance Method Summary collapse
Instance Method Details
#except_nested(key) ⇒ Object
55 56 57 58 |
# File 'lib/shipay/util.rb', line 55 def except_nested(key) r = Marshal.load(Marshal.dump(self)) r.except_nested!(key) end |
#except_nested!(key) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/shipay/util.rb', line 60 def except_nested!(key) self.reject!{|k, _| k == key || k.to_s == key } self.each do |_, v| v.except_nested!(key) if v.is_a?(Hash) v.map!{|obj| obj.except_nested!(key) if obj.is_a?(Hash)} if v.is_a?(Array) end end |