class ActiveZuora::ArrayFieldDecorator

Public Instance Methods

build_xml(xml, soap, values, options={}) click to toggle source
# File lib/active_zuora/fields/array_field_decorator.rb, line 12
def build_xml(xml, soap, values, options={})
  # It may be wierd that we're mapping and taking the last value,
  # But there's an issue with xml builder where if a block
  # returns an array, it will output the array in the XML.
  # So instead, we'll have our block return the value
  # of the last build_xml call.
  [values].flatten.compact.map do |value|
    __getobj__.build_xml(xml, soap, value, options)
  end.last
end
clear_changed_attributes(values) click to toggle source
# File lib/active_zuora/fields/array_field_decorator.rb, line 23
def clear_changed_attributes(values)
  [values].flatten.compact.map { |value| __getobj__.clear_changed_attributes(value) }
end
type_cast(values) click to toggle source

Wraps a Field object and typecasts/builds item as an array of the given field.

# File lib/active_zuora/fields/array_field_decorator.rb, line 7
def type_cast(values)
  # Force into an array and run type_cast on each element.
  [values].flatten.compact.map { |value| __getobj__.type_cast(value) }
end