lib/masterview/directive_helpers.rb in masterview-0.2.0 vs lib/masterview/directive_helpers.rb in masterview-0.2.1

- old
+ new

@@ -183,8 +183,18 @@ def lowercase_attribute_keys_and_values(attributes) lcattrs = {} attributes.each { |k,v| lcattrs[k.downcase] = v.downcase } lcattrs end + + # using hash, symbolize keys, sort keys, serialize to string + def symbolize_sort_and_serialize_hash_to_str(hash) + symbolized = {} + hash.each{ |k,v| symbolized[k.to_sym] = v } #symbolize + sorted = symbolized.sort{ |a,b| a[0].to_s <=> b[0].to_s } # sort the keys + sorted_strings = sorted.collect{ |k,v| "#{k.inspect} => '#{v}'"} # create strings + sorted_strings.join(', ') # finally combine them + end + end end