Sha256: 2af8a808a5ac6ab4546f2eb0d7776ab44291ae28d7e06058f28d585d240a2076

Contents?: true

Size: 1.38 KB

Versions: 13

Compression:

Stored size: 1.38 KB

Contents

module NetSuite
  module Records
    class CustomRecordRef
      include Support::Fields
      include Support::Records
      include Namespaces::PlatformCore

      attr_reader   :internal_id
      attr_accessor :external_id, :type_id

      def initialize(attributes_or_record = {})
        case attributes_or_record
        when Hash
          attributes = attributes_or_record
          attributes.delete(:"@xmlns:platform_core")
          @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
          @external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
          @type_id     = attributes.delete(:type_id) || attributes.delete(:@type_id)
          @type_id     = @type_id.to_s if @type_id
          initialize_from_attributes_hash(attributes)
        else
          record = attributes_or_record
          @internal_id = record.internal_id if record.respond_to?(:internal_id)
          @external_id = record.external_id if record.respond_to?(:external_id)
          @type_id     = record.class.type_id if record.class.respond_to?(:type_id) && record.class.type_id
          @type_id     = @type_id.to_s if @type_id
        end
      end

      def method_missing(m, *args, &block)
        if attributes.keys.map(&:to_sym).include?(m.to_sym)
          attributes[m.to_sym]
        else
          super
        end
      end

    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
netsuite-0.0.49 lib/netsuite/records/custom_record_ref.rb
netsuite-0.0.48 lib/netsuite/records/custom_record_ref.rb
netsuite-0.0.47 lib/netsuite/records/custom_record_ref.rb
netsuite-0.0.45 lib/netsuite/records/custom_record_ref.rb
netsuite-0.0.44 lib/netsuite/records/custom_record_ref.rb
netsuite-0.0.43 lib/netsuite/records/custom_record_ref.rb
netsuite-0.0.42 lib/netsuite/records/custom_record_ref.rb
netsuite-0.0.41 lib/netsuite/records/custom_record_ref.rb
netsuite-0.0.40 lib/netsuite/records/custom_record_ref.rb
netsuite-0.0.39 lib/netsuite/records/custom_record_ref.rb
netsuite-0.0.38 lib/netsuite/records/custom_record_ref.rb
netsuite-0.0.37 lib/netsuite/records/custom_record_ref.rb
netsuite-0.0.36 lib/netsuite/records/custom_record_ref.rb