Class: ChangeHealth::Models::Model

Inherits:
Hashie::Trash
  • Object
show all
Defined in:
lib/change_health/models/model.rb

Instance Method Summary collapse

Instance Method Details

#as_json(args = {}) ⇒ Object



40
41
42
# File 'lib/change_health/models/model.rb', line 40

def as_json(args = {})
  self.to_h
end

#to_hObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/change_health/models/model.rb', line 27

def to_h
  result = super.to_h

  self.each_pair do |key, value|
    if key.to_s.downcase.include?('date')
      result[key] = ChangeHealth::Models::DATE_FORMATTER.call(result[key])
    end
    result[key] = nil if value == ""
  end

  result
end

#to_jsonObject



44
45
46
# File 'lib/change_health/models/model.rb', line 44

def to_json
  self.to_h.to_json
end