Module: ChanPay::Utils
- Defined in:
- lib/chan_pay/utils.rb
Class Method Summary collapse
-
.symbolize_keys(hash) ⇒ Hash
把 hash 中的 key,都转化为 symbol 类型.
Class Method Details
.symbolize_keys(hash) ⇒ Hash
把 hash 中的 key,都转化为 symbol 类型
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 |