Module: HealthCards::AttributeFilters
- Included in:
- Payload
- Defined in:
- lib/health_cards/attribute_filters.rb
Overview
Handles behavior related to removing disallowed attributes from FHIR Resources
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- ALL_FHIR_RESOURCES =
:fhir_resource
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
8 9 10 |
# File 'lib/health_cards/attribute_filters.rb', line 8 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#handle_allowable(resource) ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/health_cards/attribute_filters.rb', line 59 def handle_allowable(resource) class_allowables = self.class.allowable[resource.class] return unless class_allowables allowed = resource.to_hash.keep_if { |att| class_allowables.include?(att) } resource.from_hash(allowed) end |
#handle_disallowable(resource) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/health_cards/attribute_filters.rb', line 69 def handle_disallowable(resource) class_disallowable = find_subclass_keys(self.class.disallowable, resource) return if class_disallowable.empty? all_disallowed = class_disallowable.map do |disallowed_class| self.class.disallowable[disallowed_class] end.flatten.uniq allowed = resource.to_hash.delete_if { |att| all_disallowed.include?(att) } resource.from_hash(allowed) end |