module Hashie::Extensions::MethodOverridingInitializer
MethodOverridingInitializer allows you to override default hash methods when passing in values from an existing hash. The overriden methods are aliased with two leading underscores.
@example
class MyHash < Hash include Hashie::Extensions::MethodOverridingInitializer end h = MyHash.new(zip: 'a-dee-doo-dah') h.zip # => 'a-dee-doo-dah' h.__zip # => [[['zip', 'a-dee-doo-dah']]]
Public Class Methods
new(hash = {})
click to toggle source
# File lib/hashie/extensions/method_access.rb, line 258 def initialize(hash = {}) hash.each do |key, value| skey = key.to_s redefine_method(skey) if method?(skey) self[skey] = value end end