Class: Fog::Compute::HP::Metadata
- Inherits:
-
Fog::Collection
- Object
- Array
- Fog::Collection
- Fog::Compute::HP::Metadata
- Includes:
- MetaParent
- Defined in:
- lib/fog/hp/models/compute/metadata.rb
Instance Attribute Summary
Attributes inherited from Fog::Collection
Instance Method Summary collapse
- #all ⇒ Object
- #destroy(key) ⇒ Object
- #get(key) ⇒ Object
- #new(attributes = {}) ⇒ Object
- #set(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, #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 24 25 |
# File 'lib/fog/hp/models/compute/metadata.rb', line 17 def all requires :parent if @parent.id = service.(collection_name, @parent.id).body['metadata'] = [] .each_pair {|k,v| << {"key" => k, "value" => v} } load() end end |
#destroy(key) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/fog/hp/models/compute/metadata.rb', line 27 def destroy(key) requires :parent service.(collection_name, @parent.id, key) rescue Fog::Compute::HP::NotFound nil end |
#get(key) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/fog/hp/models/compute/metadata.rb', line 34 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::HP::NotFound nil end |
#new(attributes = {}) ⇒ Object
44 45 46 47 |
# File 'lib/fog/hp/models/compute/metadata.rb', line 44 def new(attributes = {}) requires :parent super({ :parent => @parent }.merge!(attributes)) end |
#set(data = nil) ⇒ Object
49 50 51 52 |
# File 'lib/fog/hp/models/compute/metadata.rb', line 49 def set(data=nil) requires :parent service.(collection_name, @parent.id, (data)) end |
#update(data = nil) ⇒ Object
54 55 56 57 |
# File 'lib/fog/hp/models/compute/metadata.rb', line 54 def update(data=nil) requires :parent service.(collection_name, @parent.id, (data)) end |