Sha256: 442beb2812ff4ee3d417188d1783e10ab4b31eed042595509616371128968267

Contents?: true

Size: 1.54 KB

Versions: 18

Compression:

Stored size: 1.54 KB

Contents

require 'fog/core/collection'
require 'fog/openstack/models/image/image'

module Fog
  module Image
    class OpenStack
      class Images < Fog::Collection
        model Fog::Image::OpenStack::Image

        def all
          load(service.list_public_images_detailed.body['images'])
        end

        def details
          load(service.list_public_images_detailed.body['images'])
        end

        def find_by_id(id)
          self.find {|image| image.id == id}
        end

        def public
          images = load(service.list_public_images_detailed.body['images'])
          images.delete_if{|image| image.is_public == false}
        end

        def private
          images = load(service.list_public_images_detailed.body['images'])
          images.delete_if{|image| image.is_public}
        end

        def destroy(id)
          image = self.find_by_id(id)
          image.destroy
        end

        def method_missing(method_sym, *arguments, &block)
          if method_sym.to_s =~ /^find_by_(.*)$/
            load(service.list_public_images_detailed($1 ,arguments.first).body['images'])
          else
            super
          end
        end

        def find_by_size_min(size)
          find_attribute(__method__, size)
        end

        def find_by_size_max(size)
          find_attribute(__method__, size)
        end

        def find_attribute(attribute,value)
          attribute = attribute.to_s.gsub("find_by_", "")
          load(service.list_public_images_detailed(attribute , value).body['images'])
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 6 rubygems

Version Path
cifrado-0.2.1 vendor/fog/lib/fog/openstack/models/image/images.rb
cifrado-0.2.0 vendor/fog/lib/fog/openstack/models/image/images.rb
hpfog-0.0.20 lib/fog/openstack/models/image/images.rb
vagrant-shell-0.2.6 vendor/bundle/gems/fog-1.10.1/lib/fog/openstack/models/image/images.rb
vagrant-shell-0.2.5 vendor/bundle/gems/fog-1.10.1/lib/fog/openstack/models/image/images.rb
fog-1.11.1 lib/fog/openstack/models/image/images.rb
fog-1.11.0 lib/fog/openstack/models/image/images.rb
fog-1.10.1 lib/fog/openstack/models/image/images.rb
fog-test-me-1.10.0 lib/fog/openstack/models/image/images.rb
cifrado-0.1.3 vendor/fog/lib/fog/openstack/models/image/images.rb
fog-1.10.0 lib/fog/openstack/models/image/images.rb
cifrado-0.1.2 vendor/fog/lib/fog/openstack/models/image/images.rb
cifrado-0.1.1 vendor/fog/lib/fog/openstack/models/image/images.rb
cifrado-0.1 vendor/fog/lib/fog/openstack/models/image/images.rb
fog-1.9.0 lib/fog/openstack/models/image/images.rb
fog-maestrodev-1.8.0.20130114204828 lib/fog/openstack/models/image/images.rb
fog-maestrodev-1.8.0.20130111070250 lib/fog/openstack/models/image/images.rb
fog-maestrodev-1.8.0.20130109172219 lib/fog/openstack/models/image/images.rb