Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dont mutate hash object when serializing #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/case_transform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down