Sha256: 360f90d66d7b749eac8114c3acb135f1d6ffe1a509f41bb90ab9a0be53092cda
Contents?: true
Size: 935 Bytes
Versions: 10
Compression:
Stored size: 935 Bytes
Contents
module Paysafe module Refinements module CamelCase refine Hash do def to_camel_case(data = self) case data when Array data.map { |value| to_camel_case(value) } when Hash data.map { |key, value| [camel_case_key(key), to_camel_case(value)] }.to_h else data end end private def camel_case_key(key) case key when Symbol camel_case(key.to_s).to_sym when String camel_case(key).to_sym else key end end def camel_case(string) @__memoize_camelcase ||= {} return @__memoize_camelcase[string] if @__memoize_camelcase[string] @__memoize_camelcase[string] = string.gsub(/(?:_+)([a-z])/) { $1.upcase } @__memoize_camelcase[string] end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems