Class: IronBank::Object

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#payloadObject (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_underscoreObject



38
39
40
41
42
# File 'lib/iron_bank/object.rb', line 38

def deep_underscore
  @prok = UNDERSCORER

  transform(payload)
end