Class: PandaPal::Session::DataSerializer
- Inherits:
-
Object
- Object
- PandaPal::Session::DataSerializer
- Defined in:
- app/models/panda_pal/session.rb
Class Method Summary collapse
Class Method Details
.dump(obj) ⇒ Object
200 201 202 |
# File 'app/models/panda_pal/session.rb', line 200 def self.dump(obj) JSON.dump(obj) end |
.load(str) ⇒ Object
190 191 192 193 194 195 196 197 198 |
# File 'app/models/panda_pal/session.rb', line 190 def self.load(str) return {} unless str.present? begin parsed = JSON.parse(str) rescue JSON::ParserError parsed = yaml_load(str) end parsed.is_a?(Hash) ? HashWithIndifferentAccess.new(parsed) : parsed end |