Class: Fog::Storage::HP::Metadata

Inherits:
Collection
  • Object
show all
Includes:
MetaParent
Defined in:
lib/fog/hp/models/storage/metadata.rb

Instance Attribute Summary

Attributes inherited from Collection

#service

Instance Method Summary collapse

Methods included from MetaParent

#metas_to_hash, #parent, #parent=

Methods inherited from 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 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

#allObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/hp/models/storage/metadata.rb', line 15

def all
  requires :parent
  if @parent.key
     = service.head_container(@parent.key).headers
    metas = []
    .each_pair {|k,v| metas << {'key' => k, 'value' => v} }
    load(metas)
  end
rescue Fog::Storage::HP::NotFound
  nil
end

#destroyObject



27
28
29
# File 'lib/fog/hp/models/storage/metadata.rb', line 27

def destroy
  false
end

#get(key) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fog/hp/models/storage/metadata.rb', line 31

def get(key)
  requires :parent
  if @parent.key
     = service.head_container(@parent.key).headers
    metas = []
    metas << {'key' => key, 'value' => [key]}
    new(metas[0])
  end
rescue Fog::Storage::HP::NotFound
  nil
end

#new(attributes = {}) ⇒ Object



43
44
45
46
# File 'lib/fog/hp/models/storage/metadata.rb', line 43

def new(attributes = {})
  requires :parent
  super({ :parent => @parent }.merge!(attributes))
end

#set(data = nil) ⇒ Object



48
49
50
51
52
53
# File 'lib/fog/hp/models/storage/metadata.rb', line 48

def set(data=nil)
  requires :parent
  if @parent.key
    service.put_container(@parent.key, meta_hash(data))
  end
end

#update(data = nil) ⇒ Object



55
56
57
58
59
60
# File 'lib/fog/hp/models/storage/metadata.rb', line 55

def update(data=nil)
  requires :parent
  if @parent.key
    service.post_container(@parent.key, meta_hash(data))
  end
end