From dbf6020e818bc55f3a39dd4adfc66b97964151a9 Mon Sep 17 00:00:00 2001 From: John Stoecker Date: Tue, 14 Feb 2017 10:53:49 -0800 Subject: [PATCH] dont mutate hash object when serializing --- lib/case_transform.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/case_transform.rb b/lib/case_transform.rb index 57b8be6..03c4fc1 100644 --- a/lib/case_transform.rb +++ b/lib/case_transform.rb @@ -29,7 +29,7 @@ def underscore_cache def camel(value) case value when Array then value.map { |item| camel(item) } - when Hash then value.deep_transform_keys! { |key| camel(key) } + when Hash then value.deep_transform_keys { |key| camel(key) } when Symbol then camel(value.to_s).to_sym when String then camel_cache[value] ||= value.underscore.camelize else value @@ -43,7 +43,7 @@ def camel(value) def camel_lower(value) case value when Array then value.map { |item| camel_lower(item) } - when Hash then value.deep_transform_keys! { |key| camel_lower(key) } + when Hash then value.deep_transform_keys { |key| camel_lower(key) } when Symbol then camel_lower(value.to_s).to_sym when String then camel_lower_cache[value] ||= value.underscore.camelize(:lower) else value @@ -58,7 +58,7 @@ def camel_lower(value) def dash(value) case value when Array then value.map { |item| dash(item) } - when Hash then value.deep_transform_keys! { |key| dash(key) } + when Hash then value.deep_transform_keys { |key| dash(key) } when Symbol then dash(value.to_s).to_sym when String then dash_cache[value] ||= value.underscore.dasherize else value @@ -73,7 +73,7 @@ def dash(value) def underscore(value) case value when Array then value.map { |item| underscore(item) } - when Hash then value.deep_transform_keys! { |key| underscore(key) } + when Hash then value.deep_transform_keys { |key| underscore(key) } when Symbol then underscore(value.to_s).to_sym when String then underscore_cache[value] ||= value.underscore else value