Class: Fog::Image::OpenStack::Images
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
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#connection, #connection=, #prepare_service_value
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one
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
#all ⇒ Object
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
|
#details ⇒ Object
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
|
#private ⇒ Object
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
|
#public ⇒ Object
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
|