Sha256: 00b71b57ea3c5fe3cf5e86bab7e49a0957d6232d6b65720bf9486e328d15a52b
Contents?: true
Size: 1.37 KB
Versions: 2
Compression:
Stored size: 1.37 KB
Contents
# # Copyright (C) 2009 Red Hat, Inc. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA require 'deltacloud/base_driver' module ConversionHelper def convert_to_json(type, obj) if ( [ :flavor, :account, :image, :realm, :instance, :storage_volume, :storage_snapshot, :hardware_profile ].include?( type ) ) if Array.eql?(obj.class) data = obj.collect do |o| o.to_hash.merge({ :href => self.send(:"#{type}_url", type.eql?(:hardware_profile) ? o.name : o.id ) }) end type = type.to_s.pluralize else data = obj.to_hash data.merge!({ :href => self.send(:"#{type}_url", data[:id]) }) end return { :"#{type}" => data }.to_json end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
bbrowning-deltacloud-core-0.0.1.1 | lib/deltacloud/helpers/conversion_helper.rb |
deltacloud-core-0.0.2 | lib/deltacloud/helpers/conversion_helper.rb |