module Twitter::HashHelper
Public Class Methods
symbolize_keys(hash)
click to toggle source
Return a new hash with all keys converted to symbols, as long as they respond to to_sym
.
{ 'name' => 'Rob', 'years' => '28' }.symbolize_keys #=> { :name => "Rob", :years => "28" }
# File lib/twitter-text-relative/hash_helper.rb, line 8 def self.symbolize_keys(hash) hash.dup.symbolize_keys! end
symbolize_keys!(hash)
click to toggle source
Destructively convert all keys to symbols, as long as they respond to to_sym
. Same as symbolize_keys
, but modifies self
.
# File lib/twitter-text-relative/hash_helper.rb, line 14 def self.symbolize_keys!(hash) hash.keys.each do |key| hash[(key.to_sym rescue key) || key] = hash.delete(key) end hash end