Method: Deltacloud::StorageVolume#to_hash

Defined in:
lib/deltacloud/models/storage_volume.rb

#to_hash(context) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/deltacloud/models/storage_volume.rb', line 31

def to_hash(context)
  r = {
    :id => self.id,
    :href => context.storage_volume_url(self.id),
    :name => name,
    :description => description,
    :state => state,
    :created => created,
    :realm => { :id => realm_id, :href => context.realm_url(realm_id), :rel => :realm },
    :device => device,
    :kind => kind,
    :capacity => capacity,
  }
  r[:actions] = (actions || []).map { |a|
    { :href => context.send("#{a}_storage_volume_url", self.id), :rel => a }
  }
  if instance_id
    r[:instance] = { :id => instance_id, :href => context.instance_url(instance_id), :rel => :instance }
  else
    r[:instance] = {}
  end
  r
end