Class: Fog::Image::OpenStack::Images

Inherits:
Collection
  • Object
show all
Defined in:
lib/fog/openstack/models/image/images.rb

Instance Attribute Summary

Attributes inherited from Collection

#service

Instance Method Summary collapse

Methods inherited from Collection

#clear, #create, #initialize, #inspect, #load, model, #model, #new, #reload, #table, #to_json

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Collection

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *arguments, &block) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/fog/openstack/models/image/images.rb', line 38

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

Instance Method Details

#allObject



10
11
12
# File 'lib/fog/openstack/models/image/images.rb', line 10

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

#destroy(id) ⇒ Object



33
34
35
36
# File 'lib/fog/openstack/models/image/images.rb', line 33

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

#detailsObject



14
15
16
# File 'lib/fog/openstack/models/image/images.rb', line 14

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

#find_attribute(attribute, value) ⇒ Object



54
55
56
57
# File 'lib/fog/openstack/models/image/images.rb', line 54

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

#find_by_id(id) ⇒ Object Also known as: get



18
19
20
# File 'lib/fog/openstack/models/image/images.rb', line 18

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

#find_by_size_max(size) ⇒ Object



50
51
52
# File 'lib/fog/openstack/models/image/images.rb', line 50

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

#find_by_size_min(size) ⇒ Object



46
47
48
# File 'lib/fog/openstack/models/image/images.rb', line 46

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

#privateObject



28
29
30
31
# File 'lib/fog/openstack/models/image/images.rb', line 28

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

#publicObject



23
24
25
26
# File 'lib/fog/openstack/models/image/images.rb', line 23

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