Class: IronBank::Object
- Inherits:
-
Object
- Object
- IronBank::Object
- Defined in:
- lib/iron_bank/object.rb
Overview
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.
Constant Summary collapse
- UNMODIFIED_FIELD_KEYS =
%w[ fieldsToNull ].freeze
- CAMELIZER =
lambda do |type, key| return key if UNMODIFIED_FIELD_KEYS.include?(key.to_s) IronBank::Utils.camelize(key, type: type) end
- UNDERSCORER =
lambda do |key| IronBank::Utils.underscore(key).to_sym end
Instance Attribute Summary collapse
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
Instance Method Summary collapse
- #deep_camelize(type: :upper) ⇒ Object
- #deep_underscore ⇒ Object
-
#initialize(payload) ⇒ Object
constructor
A new instance of Object.
Constructor Details
#initialize(payload) ⇒ Object
Returns a new instance of Object.
28 29 30 |
# File 'lib/iron_bank/object.rb', line 28 def initialize(payload) @payload = payload end |
Instance Attribute Details
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
26 27 28 |
# File 'lib/iron_bank/object.rb', line 26 def payload @payload end |
Instance Method Details
#deep_camelize(type: :upper) ⇒ Object
32 33 34 35 36 |
# File 'lib/iron_bank/object.rb', line 32 def deep_camelize(type: :upper) @prok = CAMELIZER.curry[type] transform(payload) end |
#deep_underscore ⇒ Object
38 39 40 41 42 |
# File 'lib/iron_bank/object.rb', line 38 def deep_underscore @prok = UNDERSCORER transform(payload) end |