class Hash
This extension to the Hash class to allows object masks to be constructed from built-in Ruby types and converted to object masks strings for presentation to the SoftLayer API
Public Instance Methods
Returns a string representing the hash as a property within a larger object mask. This routine is an implementation detail used in the conversion of hashes to object mask strings. You should not have to call this method directly.
# File lib/softlayer/object_mask_helpers.rb, line 29 def _to_sl_object_mask_property() key_strings = __sl_object_mask_properties_for_keys(); "#{key_strings.join(',')}" end
Given a hash, generate an Object Mask string from the structure found within the hash. This allows object masks to be constructed as hashes, then converted to strings when they must be passed to the API. The routine does some very rudimentary validation to ensure that the hash represents a valid object mask, but care must still be taken when constructing the hash.
# File lib/softlayer/object_mask_helpers.rb, line 18 def to_sl_object_mask() raise RuntimeError, "An object mask must contain properties" if empty? raise RuntimeError, "An object mask must start with root properties" if keys().find { |key| !__valid_root_property_key?(key) } key_strings = __sl_object_mask_properties_for_keys(); key_strings.count > 1 ? "[#{key_strings.join(',')}]" : "#{key_strings[0]}" end