Module: Vcloud::Core::MetadataHelper
- Defined in:
- lib/vcloud/core/metadata_helper.rb
Class Method Summary collapse
-
.extract_metadata(vcloud_metadata_entries) ⇒ Hash
Convert the fog metadata into a hash of standard Ruby types Fog and vCloud currently expose the types used in the API, which are unnecessary for most needs.
Class Method Details
.extract_metadata(vcloud_metadata_entries) ⇒ Hash
Convert the fog metadata into a hash of standard Ruby types Fog and vCloud currently expose the types used in the API, which are unnecessary for most needs. This class maps those custom Fog types back to Ruby types if possible.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/vcloud/core/metadata_helper.rb', line 12 def = {} .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 [key] = val end end |