Module: Openphar::HarmonizedTypeRegistry

Defined in:
lib/openphar/harmonized_type_registry.rb

Overview

Frozen set of recognized harmonized type names.

Every publisher subclass's harmonized_type (when non-nil) must be in this list. Specs verify that. Catches typos at definition time.

Constant Summary collapse

RECOGNIZED =
%w[
  Monograph
  CrudeDrug
  ChemicalDrug
  Formulation
  BiologicalSubstance
  Vitamin
  AminoAcid
  MineralSubstance
  Radiopharmaceutical
  DosageForm
  TestMethod
  Reagent
  ReferenceSubstance
  GeneralChapter
].freeze

Class Method Summary collapse

Class Method Details

.allObject



41
42
43
# File 'lib/openphar/harmonized_type_registry.rb', line 41

def all
  RECOGNIZED.dup
end

.assert!(type) ⇒ Object

Raises:

  • (ArgumentError)


34
35
36
37
38
39
# File 'lib/openphar/harmonized_type_registry.rb', line 34

def assert!(type)
  return if valid?(type)

  raise ArgumentError, "unknown harmonized type: #{type.inspect}. " \
                       "Must be one of: #{RECOGNIZED.join(', ')}"
end

.valid?(type) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
31
32
# File 'lib/openphar/harmonized_type_registry.rb', line 28

def valid?(type)
  return false if type.nil?

  RECOGNIZED.include?(type.to_s)
end