Class: Motor::HashSerializer
- Inherits:
-
Object
- Object
- Motor::HashSerializer
- Defined in:
- lib/motor/hash_serializer.rb
Class Method Summary collapse
Class Method Details
.dump(hash) ⇒ Object
5 6 7 |
# File 'lib/motor/hash_serializer.rb', line 5 def self.dump(hash) hash.to_json end |
.load(hash) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/motor/hash_serializer.rb', line 9 def self.load(hash) return hash unless hash hash = JSON.parse(hash.presence || '{}') if hash.is_a?(String) if hash.is_a?(Hash) hash.with_indifferent_access else hash || {} end end |