class IronBank::Object
This object holds the initial payload sent to an action/operation. It exposes methods to convert the payload keys to either upper camel case (typically used by actions) or lower camel case.
It is also use to parse the response from Zuora and convert it into a Ruby- friendly Hash.
Constants
- CAMELIZER
- UNDERSCORER
- UNMODIFIED_FIELD_KEYS
Attributes
payload[R]
prok[R]
Public Class Methods
new(payload)
click to toggle source
# File lib/iron_bank/object.rb, line 28 def initialize(payload) @payload = payload end
Public Instance Methods
deep_camelize(type: :upper)
click to toggle source
# File lib/iron_bank/object.rb, line 32 def deep_camelize(type: :upper) @prok = CAMELIZER.curry[type] transform(payload) end
deep_underscore()
click to toggle source
# File lib/iron_bank/object.rb, line 38 def deep_underscore @prok = UNDERSCORER transform(payload) end
Private Instance Methods
transform(value)
click to toggle source
# File lib/iron_bank/object.rb, line 48 def transform(value) case value when Array then transform_array(value) when Hash then transform_hash(value) when IronBank::Object then transform(value.payload) else value end end
transform_array(array)
click to toggle source
# File lib/iron_bank/object.rb, line 57 def transform_array(array) array.map { |element| transform(element) } end
transform_hash(hash)
click to toggle source
# File lib/iron_bank/object.rb, line 61 def transform_hash(hash) hash.each.with_object({}) do |(key, value), hsh| key = prok.call(key.to_s) hsh[key] = transform(value) end end