Sha256: 6284e1eac4e58eb55cca519bf92c47ded926ec841f06f805a32789b5957ce14b

Contents?: true

Size: 800 Bytes

Versions: 30

Compression:

Stored size: 800 Bytes

Contents

module ActiveZuora
  class ObjectField < Field

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

    attr_accessor :class_name

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

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

    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

    def clear_changed_attributes(value)
      value.clear_changed_attributes if value
    end

  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
active_zuora-2.1.2 lib/active_zuora/fields/object_field.rb
active_zuora-2.1.1 lib/active_zuora/fields/object_field.rb
active_zuora-2.0.6 lib/active_zuora/fields/object_field.rb
active_zuora-2.1.0 lib/active_zuora/fields/object_field.rb
active_zuora-2.0.5 lib/active_zuora/fields/object_field.rb
active_zuora-2.0.4 lib/active_zuora/fields/object_field.rb
active_zuora-2.0.3 lib/active_zuora/fields/object_field.rb
active_zuora-2.0.2 lib/active_zuora/fields/object_field.rb
active_zuora-2.0.1 lib/active_zuora/fields/object_field.rb
active_zuora-2.0.0 lib/active_zuora/fields/object_field.rb