Class: DaVinciUSDrugFormularyTestKit::Generator::GroupMetadata

Inherits:
Object
  • Object
show all
Defined in:
lib/davinci_us_drug_formulary_test_kit/generator/group_metadata.rb

Constant Summary collapse

ATTRIBUTES =
[
  :name,
  :class_name,
  :version,
  :reformatted_version,
  :resource,
  :profile_url,
  :profile_name,
  :profile_version,
  :title,
  :short_description,
  :interactions,
  # :operations,
  :searches,
  :search_definitions,
  :include_params,
  # :revincludes,
  :must_supports,
  :mandatory_elements,
  # :bindings,
  :references,
  :tests,
  :id,
  :file_name,
  :delayed_references
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(metadata) ⇒ GroupMetadata

Returns a new instance of GroupMetadata.



33
34
35
36
37
38
39
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_metadata.rb', line 33

def initialize()
  .each do |key, value|
    raise "Unknown attribute #{key}" unless ATTRIBUTES.include? key

    instance_variable_set(:"@#{key}", value)
  end
end

Instance Method Details

#add_delayed_references(delayed_profiles, ig_resources) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_metadata.rb', line 64

def add_delayed_references(delayed_profiles, ig_resources)
  self.delayed_references =
    references
      .select { |reference| (reference[:profiles] & delayed_profiles).present? }
      .map do |reference|
        profile_urls = (reference[:profiles] & delayed_profiles)
        delayed_resources = profile_urls.map { |url| ig_resources.resource_for_profile(url) }
        {
          path: reference[:path].gsub("#{resource}.", ''),
          resources: delayed_resources
        }
      end
end

#add_test(id:, file_name:) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_metadata.rb', line 45

def add_test(id:, file_name:)
  self.tests ||= []

   = {
    id:,
    file_name:
  }

  if delayed? && id.include?('read')
    self.tests.unshift()
  else
    self.tests << 
  end
end

#delayed?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_metadata.rb', line 41

def delayed?
  false
end

#to_hashObject



60
61
62
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_metadata.rb', line 60

def to_hash
  ATTRIBUTES.each_with_object({}) { |key, hash| hash[key] = send(key) unless send(key).nil? }
end