Class: RightScale::SerializationHelper
- Defined in:
- lib/right_agent/serialize/serializable.rb
Class Method Summary collapse
-
.symbolize_keys(hash) ⇒ Object
Symbolize keys of hash, use when retrieving hashes that use symbols for keys as JSON and MessagePack serialization will produce strings instead Simply return any object that is not a hash as is.
Class Method Details
.symbolize_keys(hash) ⇒ Object
Symbolize keys of hash, use when retrieving hashes that use symbols for keys as JSON and MessagePack serialization will produce strings instead Simply return any object that is not a hash as is
Parameters
- hash(Hash)
-
Hash whose keys are to be symbolized
Return
- (Hash)
-
Hash with same values but symbol keys
138 139 140 141 142 143 144 145 146 147 |
# File 'lib/right_agent/serialize/serializable.rb', line 138 def self.symbolize_keys(hash) if hash.is_a?(Hash) hash.inject({}) do |h, (key, value)| h[(key.to_sym rescue key) || key] = value h end else hash end end |