Class: CoalescingPanda::JSONWithIndifferentAccess

Inherits:
Object
  • Object
show all
Defined in:
app/models/coalescing_panda/json_with_indifferent_access.rb

Class Method Summary collapse

Class Method Details

.dump(obj) ⇒ Object



9
10
11
# File 'app/models/coalescing_panda/json_with_indifferent_access.rb', line 9

def self.dump(obj)
  JSON.dump(obj)
end

.load(str) ⇒ Object



3
4
5
6
7
# File 'app/models/coalescing_panda/json_with_indifferent_access.rb', line 3

def self.load(str)
  return nil unless str.present?
  parsed = JSON.parse(str)
  parsed.is_a?(Hash) ? HashWithIndifferentAccess.new(parsed) : parsed
end