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:

  • (RuntimeError)

    raises excpetion if collection type for parent is unknown



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

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



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

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



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

def parent
  @parent
end

#parent=(new_parent) ⇒ Object

Sets parent of metadata

Parameters:

  • new_parent (#parent)

    of metadata



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

def parent=(new_parent)
  @parent = new_parent
end