Sha256: 2b5eac4ae4ac1983dd672932cc8fd1ea6f994230ee2fb3a27e9aca49f1f4127c
Contents?: true
Size: 870 Bytes
Versions: 17
Compression:
Stored size: 870 Bytes
Contents
# frozen_string_literal: true module Cased class Context class Expander def self.expand(payload) return {} if payload.nil? return payload unless payload.respond_to?(:each) cased_payload = payload.dup payload.each do |key, value| if value.respond_to?(:cased_context) cased_payload.delete(key) cased_payload.update(value.cased_context(category: key)) elsif value.is_a?(Hash) cased_payload[key] = expand(value) elsif value.is_a?(Array) values = value.collect do |val| if val.respond_to?(:cased_context) val.cased_context else val end end cased_payload.update(key => values) end end cased_payload end end end end
Version data entries
17 entries across 17 versions & 1 rubygems