Class: ChangeHealth::Models::Model
- Inherits:
-
Hashie::Trash
- Object
- Hashie::Trash
- ChangeHealth::Models::Model
- Defined in:
- lib/change_health/models/model.rb
Direct Known Subclasses
Claim::Address, Claim::BillingPayToAddressName, Claim::ClaimCodeInformation, Claim::ClaimDateInformation, Claim::ClaimInformation, Claim::ClaimSupplementalInformation, Claim::ContactInformation, Claim::Dependent, Claim::Diagnosis, Claim::DrugIdentification, Claim::InstitutionalService, Claim::LineAdjudicationInformation, Claim::OtherPayerName, Claim::OtherSubscriberInformation, Claim::OtherSubscriberName, Claim::ProfessionalService, Claim::Provider, Claim::Receiver, Claim::ReportInformation, Claim::ServiceFacilityLocation, Claim::ServiceLine, Claim::Submitter, Claim::Subscriber, Eligibility::Encounter, Eligibility::Subscriber
Class Method Summary collapse
-
.format_value(key, value) ⇒ Object
rubocop:enable Style/MapToHash.
-
.hashify(model) ⇒ Object
rubocop:disable Style/MapToHash.
Instance Method Summary collapse
Class Method Details
.format_value(key, value) ⇒ Object
rubocop:enable Style/MapToHash
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/change_health/models/model.rb', line 89 def self.format_value(key, value) return nil if value == '' downcased_key = key.to_s.downcase return ChangeHealth::Models.date_hour_formatter(value) if downcased_key.include?('dateandhour') return ChangeHealth::Models.hour_formatter(value) if downcased_key.include?('hour') return ChangeHealth::Models.date_formatter(value) if downcased_key.include?('date') return ChangeHealth::Models::POSTAL_CODE_FORMATTER.call(value) if downcased_key.include?('postalcode') value end |
.hashify(model) ⇒ Object
rubocop:disable Style/MapToHash
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/change_health/models/model.rb', line 68 def self.hashify(model) model.map do |key, value| formatted_value = case value when Hash hashify(model[key]) when Array value.map do |element| if element.is_a?(Hash) hashify(element) else # if it's an array of arrays, can't handle it format_value(key, element) end end else format_value(key, value) end [key, formatted_value] end.to_h end |
Instance Method Details
#as_json(_args = {}) ⇒ Object
105 106 107 |
# File 'lib/change_health/models/model.rb', line 105 def as_json(_args = {}) to_h end |
#to_h ⇒ Object
63 64 65 |
# File 'lib/change_health/models/model.rb', line 63 def to_h self.class.hashify(self) end |
#to_json(*_args) ⇒ Object
109 110 111 |
# File 'lib/change_health/models/model.rb', line 109 def to_json(*_args) to_h.to_json end |