Module: UffizziCore::Converters

Extended by:
ActionView::Helpers::NumberHelper
Defined in:
app/utils/uffizzi_core/converters.rb

Class Method Summary collapse

Class Method Details

.deep_lower_camelize_keys(object) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/utils/uffizzi_core/converters.rb', line 7

def deep_lower_camelize_keys(object)
  case object
  when Array
    object.map do |element|
      element.deep_transform_keys { |key| key.to_s.camelize(:lower) }
    end
  when Hash
    object.deep_transform_keys { |key| key.to_s.camelize(:lower) }
  else
    object
  end
end

.deep_underscore_keys(object) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/utils/uffizzi_core/converters.rb', line 20

def deep_underscore_keys(object)
  case object
  when Array
    object.map do |element|
      element.deep_transform_keys { |key| key.to_s.underscore }
    end
  when Hash
    object.deep_transform_keys { |key| key.to_s.underscore }
  else
    object
  end
end