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
359 360 361 |
# File 'app/models/panda_pal/session.rb', line 359 def self.dump(obj) JSON.dump(obj) end |
.load(str) ⇒ Object
349 350 351 352 353 354 355 356 357 |
# File 'app/models/panda_pal/session.rb', line 349 def self.load(str) return {}.with_indifferent_access 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 |