Sha256: 73c54f9983e80388ffbc10b6c87ce60d6db5865841ebd650142e21914f658637

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

require 'leeroy'
require 'leeroy/types/dash'
require 'leeroy/types/mash'
require 'leeroy/types/phase'
require 'leeroy/helpers/dumpable'
require 'leeroy/helpers/logging'

module Leeroy
  module Types
    class Image < Leeroy::Types::Dash
      include Leeroy::Helpers::Dumpable
      include Leeroy::Helpers::Logging

      property :phase, required: true, coerce: lambda {|x| Leeroy::Types::Phase.from_s(x.to_s)}
      property :aws_params

      # AWS-specific params
      property :instance_id, required: true
      property :name, required: true

      def initialize(*args, &block)
        self.aws_params = [
          :instance_id,
          :name,
        ]

        self.dump_properties = self.aws_params

        super
      end

      def run_params
        begin
          run_params = Leeroy::Types::Mash.new

          self.aws_params.each {|key| run_params.store(key.to_s, self.fetch(key))}

          logger.debug "run_params: #{run_params.inspect}"

          run_params

        rescue StandardError => e
          raise e
        end
      end

      def to_s
        self.instance_id
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
leeroy_app-0.5.4 lib/leeroy/types/image.rb
leeroy_app-0.4.0 lib/leeroy/types/image.rb
leeroy_app-0.3.1 lib/leeroy/types/image.rb
leeroy_app-0.3.0 lib/leeroy/types/image.rb