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.6.0 lib/active_zuora/fields/object_field.rb
active_zuora-2.5.4 lib/active_zuora/fields/object_field.rb
active_zuora-2.5.3 lib/active_zuora/fields/object_field.rb
active_zuora-2.5.2 lib/active_zuora/fields/object_field.rb
active_zuora-2.5.1 lib/active_zuora/fields/object_field.rb
active_zuora-2.5.0 lib/active_zuora/fields/object_field.rb
active_zuora-2.4.1 lib/active_zuora/fields/object_field.rb
active_zuora-2.4.0 lib/active_zuora/fields/object_field.rb
active_zuora-2.3.1 lib/active_zuora/fields/object_field.rb
active_zuora-2.3.0 lib/active_zuora/fields/object_field.rb
active_zuora-2.2.7 lib/active_zuora/fields/object_field.rb
active_zuora-2.2.6 lib/active_zuora/fields/object_field.rb
active_zuora-2.2.5 lib/active_zuora/fields/object_field.rb
active_zuora-2.2.4 lib/active_zuora/fields/object_field.rb
active_zuora-2.2.3 lib/active_zuora/fields/object_field.rb
active_zuora-2.2.2 lib/active_zuora/fields/object_field.rb
active_zuora-2.2.1 lib/active_zuora/fields/object_field.rb
active_zuora-2.2.0 lib/active_zuora/fields/object_field.rb
active_zuora-2.1.4 lib/active_zuora/fields/object_field.rb
active_zuora-2.1.3 lib/active_zuora/fields/object_field.rb