Sha256: e2e71534b3c575f257d38df43a615d6cd3efc7af38b57f23a5d54081c97e5537

Contents?: true

Size: 1.1 KB

Versions: 56

Compression:

Stored size: 1.1 KB

Contents

module Fog
  module Compute
    class RackspaceV2
      module MetaParent

        # Parent of metadata 
        # @return [#parent] parent of metadata
        def parent
          @parent
        end

        # Sets parent of metadata
        # @param [#parent] new_parent of metadata
        def parent=(new_parent)
          @parent = new_parent
        end

        # Collection type for parent
        # @return [String] collection type
        # @raise [RuntimeError] raises excpetion if collection type for parent is unknown
        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

        # Converts metadata to hash
        # @return [Hash] hash containing key value pairs for metadata
        def metas_to_hash(metas)
          hash = {}
          metas.each { |meta| hash[meta.key] = meta.value }
          hash
        end

      end
    end
  end
end

Version data entries

56 entries across 56 versions & 4 rubygems

Version Path
fog-maestrodev-1.20.0.20140305101839 lib/fog/rackspace/models/compute_v2/meta_parent.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/rackspace/models/compute_v2/meta_parent.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/rackspace/models/compute_v2/meta_parent.rb
fog-1.20.0 lib/fog/rackspace/models/compute_v2/meta_parent.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/rackspace/models/compute_v2/meta_parent.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/rackspace/models/compute_v2/meta_parent.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/rackspace/models/compute_v2/meta_parent.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/rackspace/models/compute_v2/meta_parent.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/rackspace/models/compute_v2/meta_parent.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/rackspace/models/compute_v2/meta_parent.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/rackspace/models/compute_v2/meta_parent.rb
fog-1.19.0 lib/fog/rackspace/models/compute_v2/meta_parent.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/rackspace/models/compute_v2/meta_parent.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/rackspace/models/compute_v2/meta_parent.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/rackspace/models/compute_v2/meta_parent.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/rackspace/models/compute_v2/meta_parent.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/rackspace/models/compute_v2/meta_parent.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/rackspace/models/compute_v2/meta_parent.rb
fog-maestrodev-1.18.0.20131209090811 lib/fog/rackspace/models/compute_v2/meta_parent.rb
fog-maestrodev-1.18.0.20131206115947 lib/fog/rackspace/models/compute_v2/meta_parent.rb