class ReactWebpackRails::Services::CamelizeKeys
Public Class Methods
call(data)
click to toggle source
# File lib/react_webpack_rails/services/camelize_keys.rb, line 12 def self.call(data) new.call(data) end
Public Instance Methods
call(data)
click to toggle source
# File lib/react_webpack_rails/services/camelize_keys.rb, line 4 def call(data) case data.class.name when 'Array' then data.map { |element| call(element) } when 'Hash' then camelize_hash(data) else data end end
Private Instance Methods
camelize_hash(data)
click to toggle source
# File lib/react_webpack_rails/services/camelize_keys.rb, line 18 def camelize_hash(data) data.inject({}) do |hash, (key, value)| hash[key.to_s.camelize(:lower)] = call(value) hash end end