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

method?(name) click to toggle source
# File lib/hashie/extensions/method_access.rb, line 162
def method?(name)
  methods.map(&:to_s).include?(name)
end
redefine_method(method_name) click to toggle source
# File lib/hashie/extensions/method_access.rb, line 166
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