Sha256: 55700e15013bad7c8896d924e37d6dce18fc3d4d1d64e050bcfed22475172fad

Contents?: true

Size: 863 Bytes

Versions: 6

Compression:

Stored size: 863 Bytes

Contents

module Vcloud
  module Core
    module MetadataHelper

      def extract_metadata vcloud_metadata_entries
        metadata = {}
        vcloud_metadata_entries.each do |entry|
          next unless entry[:type] == Vcloud::Core::Fog::ContentTypes::METADATA
          key = entry[:Key].to_sym
          val = entry[:TypedValue][:Value]
          case entry[:TypedValue][:xsi_type]
            when Fog::MetadataValueType::Number
              val = val.to_i
            when Fog::MetadataValueType::String
              val = val.to_s
            when Fog::MetadataValueType::DateTime
              val = DateTime.parse(val)
            when Fog::MetadataValueType::Boolean
              val = val == 'true' ? true : false
          end
          metadata[key] = val
        end
        metadata
      end

      module_function :extract_metadata
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
vcloud-core-0.13.0 lib/vcloud/core/metadata_helper.rb
vcloud-core-0.12.0 lib/vcloud/core/metadata_helper.rb
vcloud-core-0.11.0 lib/vcloud/core/metadata_helper.rb
vcloud-core-0.10.0 lib/vcloud/core/metadata_helper.rb
vcloud-core-0.9.0 lib/vcloud/core/metadata_helper.rb
vcloud-core-0.8.0 lib/vcloud/core/metadata_helper.rb