Class: Fog::Compute::OpenStack::Metadata
- Inherits:
-
Fog::Collection
- Object
- Array
- Fog::Collection
- Fog::Compute::OpenStack::Metadata
- Includes:
- MetaParent
- Defined in:
- lib/fog/openstack/models/compute/metadata.rb
Instance Attribute Summary
Attributes inherited from Fog::Collection
Instance Method Summary collapse
- #all ⇒ Object
- #get(key) ⇒ Object
- #new(attributes = {}) ⇒ Object
- #set(data = nil) ⇒ Object
- #to_hash(data = nil) ⇒ Object
- #update(data = nil) ⇒ Object
Methods included from MetaParent
#collection_name, #metas_to_hash, #parent, #parent=
Methods inherited from Fog::Collection
#clear, #create, #destroy, #initialize, #inspect, #load, model, #model, #reload, #table, #to_json
Methods included from Attributes::ClassMethods
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
Methods included from Fog::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
Instance Method Details
#all ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/fog/openstack/models/compute/metadata.rb', line 17 def all requires :parent = service.(collection_name, @parent.id).body['metadata'] = [] .each_pair {|k,v| << {"key" => k, "value" => v} } unless .nil? load() end |
#get(key) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/fog/openstack/models/compute/metadata.rb', line 25 def get(key) requires :parent data = service.(collection_name, @parent.id, key).body["meta"] = [] data.each_pair {|k,v| << {"key" => k, "value" => v} } new([0]) rescue Fog::Compute::OpenStack::NotFound nil end |
#new(attributes = {}) ⇒ Object
45 46 47 48 |
# File 'lib/fog/openstack/models/compute/metadata.rb', line 45 def new(attributes = {}) requires :parent super({ :parent => @parent }.merge!(attributes)) end |
#set(data = nil) ⇒ Object
40 41 42 43 |
# File 'lib/fog/openstack/models/compute/metadata.rb', line 40 def set(data=nil) requires :parent service.(collection_name, @parent.id, to_hash(data)) end |
#to_hash(data = nil) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/fog/openstack/models/compute/metadata.rb', line 50 def to_hash(data=nil) if data.nil? data={} self.each do || if .is_a?(Fog::Compute::OpenStack::Metadatum) then data.store(.key, .value) else data.store(["key"], ["value"]) end end end data end |
#update(data = nil) ⇒ Object
35 36 37 38 |
# File 'lib/fog/openstack/models/compute/metadata.rb', line 35 def update(data=nil) requires :parent service.(collection_name, @parent.id, to_hash(data)) end |