Sha256: 7639d882d78455a7ae072f3a37115394cdce9fe04c5f54d386afd6d2d06aff75
Contents?: true
Size: 1.18 KB
Versions: 9
Compression:
Stored size: 1.18 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:) super() @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