Sha256: f564734a10a712829e144efb51a8bea0420fbe6c5b2d6b07e3e2de0c09df119c

Contents?: true

Size: 842 Bytes

Versions: 8

Compression:

Stored size: 842 Bytes

Contents

module Fog
  module AWS
    class EC2

      def images
        Fog::AWS::EC2::Images.new(:connection => self)
      end

      class Images < Fog::Collection

        attribute :image_id

        model Fog::AWS::EC2::Image

        def initialize(attributes)
          @image_id ||= []
          super
        end

        def all(image_id = @image_id)
          @image_id = image_id
          if @loaded
            clear
          end
          @loaded = true
          data = connection.describe_images('ImageId' => image_id).body
          data['imagesSet'].each do |image|
            self << new(image)
          end
          self
        end

        def get(image_id)
          if image_id
            all(image_id).first
          end
        rescue Excon::Errors::BadRequest
          nil
        end
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fog-0.0.47 lib/fog/aws/models/ec2/images.rb
fog-0.0.46 lib/fog/aws/models/ec2/images.rb
fog-0.0.45 lib/fog/aws/models/ec2/images.rb
fog-0.0.44 lib/fog/aws/models/ec2/images.rb
fog-0.0.43 lib/fog/aws/models/ec2/images.rb
fog-0.0.42 lib/fog/aws/models/ec2/images.rb
fog-0.0.41 lib/fog/aws/models/ec2/images.rb
fog-0.0.40 lib/fog/aws/models/ec2/images.rb