Class: Renalware::Pathology::ObservationsJsonbSerializer

Inherits:
Object
  • Object
show all
Defined in:
app/models/renalware/pathology/observations_jsonb_serializer.rb

Class Method Summary collapse

Class Method Details

.dump(hash) ⇒ Object



46
47
48
# File 'app/models/renalware/pathology/observations_jsonb_serializer.rb', line 46

def self.dump(hash)
  JSON.parse hash.to_json
end

.load(hash) ⇒ Object



50
51
52
53
54
# File 'app/models/renalware/pathology/observations_jsonb_serializer.rb', line 50

def self.load(hash)
  type_check(hash)
    .with_indifferent_access
    .extend(ObservationSetMethods)
end

.type_check(hash) ⇒ Object



56
57
58
59
60
61
# File 'app/models/renalware/pathology/observations_jsonb_serializer.rb', line 56

def self.type_check(hash)
  if hash.nil? then {}
  elsif hash.is_a?(Hash) then hash
  else JSON.parse(hash)
  end
end