Sha256: 8c28ea13f36cddd8cd33dfcc89bd9a5c07b6da480ff11be5664126db7fcb08f8

Contents?: true

Size: 853 Bytes

Versions: 8

Compression:

Stored size: 853 Bytes

Contents

module Awspec::Type
  class Ebs < Base
    attr_reader :volume

    def initialize(id)
      super
      @volume = find_ebs(id)
      @id = @volume[:volume_id] if @volume
    end

    states = %w(
      creating available in-use deleting deleted error
    )

    states.each do |state|
      define_method state.tr('-', '_') + '?' do
        @volume[:state] == state
      end
    end

    def method_missing(name)
      describe = name.to_sym
      if @volume.members.include?(describe)
        @volume[describe]
      else
        super
      end
    end

    def attached_to?(instance_id)
      instance = find_ec2(instance_id)
      return false unless instance
      return false unless @volume[:attachments]
      @volume[:attachments][0][:instance_id] == instance[:instance_id] && @volume[:attachments][0][:state] == 'attached'
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
awspec-0.8.0 lib/awspec/type/ebs.rb
awspec-0.7.0 lib/awspec/type/ebs.rb
awspec-0.6.4 lib/awspec/type/ebs.rb
awspec-0.6.3 lib/awspec/type/ebs.rb
awspec-0.6.2 lib/awspec/type/ebs.rb
awspec-0.6.1 lib/awspec/type/ebs.rb
awspec-0.6.0 lib/awspec/type/ebs.rb
awspec-0.5.0 lib/awspec/type/ebs.rb