Module: Fog::Compute::RackspaceV2::MetaParent

Included in:
Metadata, Metadatum
Defined in:
lib/fog/rackspace/models/compute_v2/meta_parent.rb

Instance Method Summary collapse

Instance Method Details

#collection_nameString

Collection type for parent

Returns:

  • (String)

    collection type

Raises:

  • (RuntimeException)

    raises excpetion if collection type for parent is unknown



21
22
23
24
25
26
27
28
29
# File 'lib/fog/rackspace/models/compute_v2/meta_parent.rb', line 21

def collection_name
  if parent.class == Fog::Compute::RackspaceV2::Image
    return "images"
  elsif parent.class == Fog::Compute::RackspaceV2::Server
    return "servers"
  else
    raise "Metadata is not supported for this model type."
  end
end

#metas_to_hash(metas) ⇒ Hash

Converts metadata to hash

Returns:

  • (Hash)

    hash containing key value pairs for metadata



33
34
35
36
37
# File 'lib/fog/rackspace/models/compute_v2/meta_parent.rb', line 33

def metas_to_hash(metas)
  hash = {}
  metas.each { |meta| hash[meta.key] = meta.value }
  hash
end

#parent#parent

Parent of metadata

Returns:

  • (#parent)

    parent of metadata



8
9
10
# File 'lib/fog/rackspace/models/compute_v2/meta_parent.rb', line 8

def parent
  @parent
end

#parent=(new_parent) ⇒ Object

Sets parent of metadata

Parameters:

  • new_parent (#parent)

    of metadata



14
15
16
# File 'lib/fog/rackspace/models/compute_v2/meta_parent.rb', line 14

def parent=(new_parent)
  @parent = new_parent
end