module Hashie::Extensions::Mash::KeepOriginalKeys

def self.included(descendant)

def self.included(descendant)
  error_message = "#{descendant} is not a kind of Hashie::Mash"
  raise ArgumentError, error_message unless descendant <= Hashie::Mash
end

def __convert(key)

Returns:
  • (Object, String, Symbol) - the converted key.

Parameters:
  • key (Object, String, Symbol) -- the key to convert.
def __convert(key)
  case key
  when Symbol then key.to_s
  when String then key.to_sym
  else key
  end
end

def convert_key(key)

Returns:
  • (Object) - the value assigned to the key.

Parameters:
  • key (Object, String, Symbol) -- the key to access.
def convert_key(key)
  if regular_key?(key)
    key
  elsif (converted_key = __convert(key)) && regular_key?(converted_key)
    converted_key
  else
    key
  end
end