Module: HealthCards::PayloadTypes

Included in:
Payload
Defined in:
lib/health_cards/payload_types.rb

Overview

Handles behavior related to support types by Payload subclasses

Instance Method Summary collapse

Instance Method Details

#additional_types(*add_types) ⇒ Array

Additional type claims this Payload class supports if used as a getter

Parameters:

  • types (String, Array)

    A string or array of string representing the additional type claims or nil

Returns:

  • (Array)

    the additional types added by this classes



10
11
12
13
14
# File 'lib/health_cards/payload_types.rb', line 10

def additional_types(*add_types)
  @additional_types ||= []
  @additional_types.concat(add_types) unless add_types.nil?
  @additional_types
end

#supports_type?(*type) ⇒ Boolean

Check if this class supports the given type claim(s)

Parameters:

  • type (Array, String)

    A type as defined by the SMART Health Cards framework

Returns:

  • (Boolean)

    Whether or not the type param is included in the types supported by the Payload (sub)class



25
26
27
# File 'lib/health_cards/payload_types.rb', line 25

def supports_type?(*type)
  !types.intersection(type.flatten).empty?
end

#typesArray

Type claims supported by this Payload subclass

Returns:

  • (Array)

    an array of Strings with all the supported type claims



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

def types
  @types ||= self == HealthCards::Payload ? additional_types : superclass.types + additional_types
end