Sha256: 0db5062c2ba0b3e2f20745628d44f4cdc05b42edfcd0922bd6048ef8333622d8
Contents?: true
Size: 1.16 KB
Versions: 9
Compression:
Stored size: 1.16 KB
Contents
module Tdc module DefinitionResolvers # # Knows how to resolve the tag value for the specified instance_definition key by replacing it # with an object sourced from the current catalog. # class TagResolver < Tdc::DefinitionResolvers::DefinitionResolver attr_reader :key, :source def initialize(key:, source:) @key = key @source = source end def resolve(instance_definition) return unless instance_definition.key?(key) # Lookup the source catalog entry in the current_catalog. catalog_entry = instance_eval("current_catalog.#{source}", __FILE__, __LINE__) # Before resolution the instance definition value is a tag. tag = instance_definition[key] # Use the tag to source an object from the current catalog. sourced_object = catalog_entry.send(tag) unless sourced_object message = "Could not find a tag reference for '#{key}' in the catalog entries provided." raise Tdc::FatalError, message end # Replace the tag value with the sourced object. instance_definition[key] = sourced_object end end end end
Version data entries
9 entries across 9 versions & 1 rubygems