Class: ActiveZuora::ObjectField

Inherits:
Field
  • Object
show all
Defined in:
lib/active_zuora/fields/object_field.rb

Instance Attribute Summary collapse

Attributes inherited from Field

#default, #name, #namespace, #zuora_name

Instance Method Summary collapse

Methods inherited from Field

#define_instance_methods

Constructor Details

#initialize(name, namespace, class_name, options = {}) ⇒ ObjectField

Returns a new instance of ObjectField.


9
10
11
12
# File 'lib/active_zuora/fields/object_field.rb', line 9

def initialize(name, namespace, class_name, options={})
  @class_name = class_name
  super(name, namespace, options)
end

Instance Attribute Details

#class_nameObject

A field that is itself another Zuora complex type. Hashes will automatically be converted to an instance of the given class.


7
8
9
# File 'lib/active_zuora/fields/object_field.rb', line 7

def class_name
  @class_name
end

Instance Method Details

#build_xml(xml, soap, value, options = {}) ⇒ Object


21
22
23
24
# File 'lib/active_zuora/fields/object_field.rb', line 21

def build_xml(xml, soap, value, options={})
  # For complex types, simply omit it if it's nil.
  value.build_xml(xml, soap, :namespace => namespace, :element_name => zuora_name) if value
end

#clear_changed_attributes(value) ⇒ Object


26
27
28
# File 'lib/active_zuora/fields/object_field.rb', line 26

def clear_changed_attributes(value)
  value.clear_changed_attributes if value
end

#type_cast(value) ⇒ Object


14
15
16
17
18
19
# File 'lib/active_zuora/fields/object_field.rb', line 14

def type_cast(value)
  if value.is_a?(Hash)
    value = class_name.constantize.new(value)
  end
  value
end