Module: Hashie::Extensions::MethodOverridingInitializer
- Includes:
- RedefineMethod
- Defined in:
- lib/hashie/extensions/method_access.rb
Overview
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.
Instance Method Summary collapse
Instance Method Details
#initialize(hash = {}) ⇒ Object
258 259 260 261 262 263 264 |
# 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 |