module Hashie::Extensions::RedefineMethod
A module shared between MethodOverridingWriter
and MethodOverridingInitializer
to contained shared logic. This module aids in redefining existing hash methods.
Protected Instance Methods
Source
# File lib/hashie/extensions/method_access.rb, line 164 def method?(name) methods.map(&:to_s).include?(name) end
Source
# File lib/hashie/extensions/method_access.rb, line 168 def redefine_method(method_name) eigenclass = class << self; self; end eigenclass.__send__(:alias_method, "__#{method_name}", method_name) eigenclass.__send__(:define_method, method_name, -> { self[method_name] }) end