Sha256: 83f6608a727a9ca365b400017730649f89a8a001bb0038d2458a0e4cd566366d

Contents?: true

Size: 1.28 KB

Versions: 6

Compression:

Stored size: 1.28 KB

Contents

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

      attr_reader   :internal_id, :type
      attr_accessor :external_id

      def initialize(attributes_or_record = {})
        case attributes_or_record
        when Hash
          attributes_or_record.delete(:"@xmlns:platform_core")
          @internal_id = attributes_or_record.delete(:internal_id) || attributes_or_record.delete(:@internal_id)
          @external_id = attributes_or_record.delete(:external_id) || attributes_or_record.delete(:@external_id)
          @type        = attributes_or_record.delete(:type) || attributes_or_record.delete(:@type)
          @attributes  = attributes_or_record
        else
          @internal_id = attributes_or_record.internal_id if attributes_or_record.respond_to?(:internal_id)
          @external_id = attributes_or_record.external_id if attributes_or_record.respond_to?(:external_id)
          @type        = attributes_or_record.class.to_s.split('::').last.lower_camelcase
        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

6 entries across 6 versions & 1 rubygems

Version Path
netsuite-0.0.17 lib/netsuite/records/record_ref.rb
netsuite-0.0.16 lib/netsuite/records/record_ref.rb
netsuite-0.0.15 lib/netsuite/records/record_ref.rb
netsuite-0.0.14 lib/netsuite/records/record_ref.rb
netsuite-0.0.13 lib/netsuite/records/record_ref.rb
netsuite-0.0.12 lib/netsuite/records/record_ref.rb