Sha256: f8c5021d08f60bb8166b6e92d9c51407ef75e674bce00a569784916ab854105f

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

module IpaTestKit
  class Generator
    class IGResources
      def add(resource)
        resources_by_type[resource.resourceType] << resource
      end

      def capability_statement(mode = 'server')
        resources_by_type['CapabilityStatement'].find do |capability_statement_resource|
          capability_statement_resource.rest.any? { |r| r.mode == mode }
        end
      end

      def ig
        resources_by_type['ImplementationGuide'].first
      end

      def inspect
        'IGResources'
      end

      def profile_by_url(url)
        resources_by_type['StructureDefinition'].find { |profile| profile.url == url }
      end

      def resource_for_profile(url)
        resources_by_type['StructureDefinition'].find { |profile| profile.url == url }.type
      end

      def value_set_by_url(url)
        resources_by_type['ValueSet'].find { |profile| profile.url == url }
      end

      def search_param_by_resource_and_name(resource, name)
        normalized_name = name.to_s == '_id' ? 'id' : name.to_s

        resources_by_type['SearchParameter']
          .find { |param| param.id == "ipa-#{resource.downcase}-#{normalized_name}" }
      end

      private

      def resources_by_type
        @resources_by_type ||= Hash.new { |hash, key| hash[key] = [] }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ipa_test_kit-0.2.0 lib/ipa_test_kit/generator/ig_resources.rb