Sha256: ff149c40d845444852c63686d25f60786f24ce37043688f2716dfd53fb7dcded

Contents?: true

Size: 1.47 KB

Versions: 53

Compression:

Stored size: 1.47 KB

Contents

module NetSuite
  module Records
    class MatrixOptionList
      # Deals with both hash and arrays of attributes[:matrix_option_list]
      #
      # Hash:
      #
      #   <listAcct:matrixOptionList>
      #     <listAcct:matrixOption internalId="47" scriptId="custitem15">
      #       <platformCore:value internalId="2" typeId="36"/>
      #     </listAcct:matrixOption>
      #   </listAcct:matrixOptionList>
      #
      # Array:
      #
      #   <listAcct:matrixOptionList>
      #     <listAcct:matrixOption internalId="45" scriptId="custitem13">
      #       <platformCore:value internalId="4" typeId="28"/>
      #     </listAcct:matrixOption>
      #     <listAcct:matrixOption internalId="46" scriptId="custitem14">
      #       <platformCore:value internalId="1" typeId="29"/>
      #     </listAcct:matrixOption>
      #   </listAcct:matrixOptionList>
      #
      def initialize(attributes = {})
        case attributes[:matrix_option]
        when Hash
          options << OpenStruct.new(
            type_id: attributes[:matrix_option][:value][:'@type_id'],
            value_id: attributes[:matrix_option][:value][:'@internal_id']
          )
        when Array
          attributes[:matrix_option].each do |option|
            options << OpenStruct.new(
              type_id: option[:value][:'@type_id'],
              value_id: option[:value][:'@internal_id']
            )
          end
        end
      end

      def options
        @options ||= []
      end
    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
netsuite-0.8.4 lib/netsuite/records/matrix_option_list.rb
netsuite-0.8.3 lib/netsuite/records/matrix_option_list.rb
netsuite-0.8.2 lib/netsuite/records/matrix_option_list.rb
netsuite-0.8.1 lib/netsuite/records/matrix_option_list.rb
netsuite-0.8.0 lib/netsuite/records/matrix_option_list.rb
netsuite-0.7.9 lib/netsuite/records/matrix_option_list.rb
netsuite-0.7.8 lib/netsuite/records/matrix_option_list.rb
netsuite-0.7.7 lib/netsuite/records/matrix_option_list.rb
netsuite-0.7.6 lib/netsuite/records/matrix_option_list.rb
netsuite-0.7.5 lib/netsuite/records/matrix_option_list.rb
netsuite-0.7.4 lib/netsuite/records/matrix_option_list.rb
netsuite-0.7.3 lib/netsuite/records/matrix_option_list.rb
netsuite-0.7.2 lib/netsuite/records/matrix_option_list.rb
netsuite-0.7.1 lib/netsuite/records/matrix_option_list.rb
netsuite-0.7.0 lib/netsuite/records/matrix_option_list.rb
netsuite-0.6.9 lib/netsuite/records/matrix_option_list.rb
netsuite-0.6.8 lib/netsuite/records/matrix_option_list.rb
netsuite-0.6.7 lib/netsuite/records/matrix_option_list.rb
netsuite-0.6.6 lib/netsuite/records/matrix_option_list.rb
netsuite-0.6.5 lib/netsuite/records/matrix_option_list.rb