module Payments
  module HashExt
    def stringify_keys
      inject({}) do |options, (key, value)|
        options[key.to_s] = value
        options
      end
    end

    def stringify_keys!
      keys.each do |key|
        self[key.to_s] = delete(key)
      end
      self
    end

    def symbolize_keys
      inject({}) do |options, (key, value)|
        options[(key.to_sym rescue key) || key] = value
        options
      end
    end

    def symbolize_keys!
      self.replace(self.symbolize_keys)
    end
  end
end

class Hash
  include Payments::HashExt
end