module Hashie::Extensions::Coercion::InstanceMethods

def custom_writer(key, value, _convert = true)

def custom_writer(key, value, _convert = true)
  self[key] = value
end

def replace(other_hash)

def replace(other_hash)
  (keys - other_hash.keys).each { |key| delete(key) }
  other_hash.each { |key, value| self[key] = value }
  self
end

def set_value_with_coercion(key, value)

def set_value_with_coercion(key, value)
  into = self.class.key_coercion(key) || self.class.value_coercion(value)
  unless value.nil? || into.nil?
    begin
      value = self.class.fetch_coercion(into).call(value)
    rescue NoMethodError, TypeError => e
      raise CoercionError.new(key, value, into, e.message)
    end
  end
  set_value_without_coercion(key, value)
end