Module: HealthCards::AttributeFilters::ClassMethods

Defined in:
lib/health_cards/attribute_filters.rb

Overview

Class level methods for Payload class specific settings

Instance Method Summary collapse

Instance Method Details

#allow(type:, attributes: []) ⇒ Object

Define allowed attributes for this Payload class

Parameters:

  • type (Class)

    Scopes the attributes to a specific class. Must be a subclass of FHIR::Model

  • attributes (Array) (defaults to: [])

    An array of string with the attribute names that will be passed through when data is minimized



18
19
20
# File 'lib/health_cards/attribute_filters.rb', line 18

def allow(type:, attributes: [])
  allowable[type] = attributes
end

#allowableHash

Define allowed attributes for this Payload class

Returns:

  • (Hash)

    A hash of FHIR::Model subclasses and attributes that will pass through minimization



42
43
44
45
46
# File 'lib/health_cards/attribute_filters.rb', line 42

def allowable
  return @allowable if @allowable

  @allowable = parent_allowables
end

#disallow(type: ALL_FHIR_RESOURCES, attributes: []) ⇒ Object

Define disallowed attributes for this Payload class To apply a rule to all FHIR types (resources and types), use FHIR::Model as the type

Parameters:

  • type (Class) (defaults to: ALL_FHIR_RESOURCES)

    Scopes the attributes to a specific class. If not used will default to all FHIR resources.

  • attributes (Array) (defaults to: [])

    An array of string with the attribute names that will be passed through when data is minimized



27
28
29
30
# File 'lib/health_cards/attribute_filters.rb', line 27

def disallow(type: ALL_FHIR_RESOURCES, attributes: [])
  disallowable[type] ||= []
  disallowable[type].concat(attributes)
end

#disallowableHash

Define disallowed attributes for this Payload class

Returns:

  • (Hash)

    A hash of FHIR::Model subclasses and attributes that will pass through minimization



34
35
36
37
38
# File 'lib/health_cards/attribute_filters.rb', line 34

def disallowable
  return @disallowable if @disallowable

  @disallowable = parent_disallowables
end