lib/ably/modules/conversions.rb in ably-0.7.0 vs lib/ably/modules/conversions.rb in ably-0.7.1

- old
+ new

@@ -56,9 +56,19 @@ end end. join end + # Convert a Hash into a mixed case Hash objet + # i.e. { client_id: 1 } becomes { 'clientId' => 1 } + def convert_to_mixed_case_hash(hash, options = {}) + raise ArgumentError, 'Hash expected' unless hash.kind_of?(Hash) + hash.each_with_object({}) do |pair, new_hash| + key, val = pair + new_hash[convert_to_mixed_case(key, options)] = val + end + end + # Convert key to :snake_case from snakeCase def convert_to_snake_case_symbol(key) key.to_s.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2').