Module: ChanPay::Utils

Defined in:
lib/chan_pay/utils.rb

Class Method Summary collapse

Class Method Details

.symbolize_keys(hash) ⇒ Hash

把 hash 中的 key,都转化为 symbol 类型

Parameters:

  • hash (Hash)

    需要更改的 hash

Returns:

  • (Hash)

    更改后的 hash



12
13
14
15
16
17
18
# File 'lib/chan_pay/utils.rb', line 12

def self.symbolize_keys(hash)
  new_hash = {}
  hash.each do |key, value|
    new_hash[(key.to_sym rescue key) || key] = value
  end
  new_hash
end