Sha256: c14d96dbf1ef0d26aa34567cd2bf220a4d0fd5c8b3292fcc7344bb830c41ce37

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

module SimpleDeploy
  module Misc
    class AttributeMerger

      def merge(args)
        @attributes   = args[:attributes]
        @config       = args[:config]
        @environment  = args[:environment]
        @logger       = args[:logger]
        @input_stacks = args[:input_stacks]
        @template     = args[:template]

        combine_provided_and_mapped_attributes
      end

      private

      def combine_provided_and_mapped_attributes
        @attributes + mapped_attributes_not_provided
      end

      def mapped_attributes
        mapper.map_outputs_from_stacks :stacks   => @input_stacks,
                                       :template => @template
      end

      def mapped_attributes_not_provided
        mapped_attributes.reject do |a|
          provided_attribute_keys.include? a.keys.first
        end
      end

      def provided_attribute_keys
        @attributes.map {|a| a.keys.first}
      end

      def mapper
        @om ||= Stack::OutputMapper.new :environment => @environment,
                                        :config      => @config,
                                        :logger      => @logger
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
simple_deploy-0.7.2 lib/simple_deploy/misc/attribute_merger.rb
simple_deploy-0.7.2.beta.1 lib/simple_deploy/misc/attribute_merger.rb
simple_deploy-0.7.1 lib/simple_deploy/misc/attribute_merger.rb
simple_deploy-0.7.0 lib/simple_deploy/misc/attribute_merger.rb