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

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

Instance Method Summary collapse

Methods included from MetaParent

#metas_to_hash, #parent, #parent=

Instance Method Details

#allObject



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

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



25
26
27
# File 'lib/fog/hp/models/storage/metadata.rb', line 25

def destroy
  false
end

#get(key) ⇒ Object



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

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



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

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

#set(data = nil) ⇒ Object



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

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

#update(data = nil) ⇒ Object



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

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