module ActiveModelSerializers::KeyTransform
def camel(value)
- See: {https://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflector/methods.rb#L66-L76 - ActiveSupport::Inflector.camelize}
def camel(value) case value when Hash then value.deep_transform_keys! { |key| camel(key) } when Symbol then camel(value.to_s).to_sym when String then value.underscore.camelize else value end end
def camel_lower(value)
- See: {https://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflector/methods.rb#L66-L76 - ActiveSupport::Inflector.camelize}
def camel_lower(value) case value when Hash then value.deep_transform_keys! { |key| camel_lower(key) } when Symbol then camel_lower(value.to_s).to_sym when String then value.underscore.camelize(:lower) else value end end
def dash(value)
- See: {https://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflector/methods.rb#L185-L187 - ActiveSupport::Inflector.dasherize}
def dash(value) case value when Hash then value.deep_transform_keys! { |key| dash(key) } when Symbol then dash(value.to_s).to_sym when String then value.underscore.dasherize else value end end
def unaltered(value)
def unaltered(value) value end
def underscore(value)
- See: {https://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflector/methods.rb#L89-L98 - ActiveSupport::Inflector.underscore}
def underscore(value) case value when Hash then value.deep_transform_keys! { |key| underscore(key) } when Symbol then underscore(value.to_s).to_sym when String then value.underscore else value end end