Sha256: eca2c80e37fa29d48b8e71d21e0488d32f77c7133c5fc4e094a414a2c85d640f

Contents?: true

Size: 1.25 KB

Versions: 63

Compression:

Stored size: 1.25 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 = 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        = attributes.delete(:type) || attributes.delete(:@type) || attributes.delete(:"@xsi:type")
          @attributes  = 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        = 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

63 entries across 63 versions & 1 rubygems

Version Path
netsuite-0.8.11 lib/netsuite/records/record_ref.rb
netsuite-0.8.10 lib/netsuite/records/record_ref.rb
netsuite-0.8.9 lib/netsuite/records/record_ref.rb
netsuite-0.8.8 lib/netsuite/records/record_ref.rb
netsuite-0.8.7 lib/netsuite/records/record_ref.rb
netsuite-0.8.6 lib/netsuite/records/record_ref.rb
netsuite-0.8.5 lib/netsuite/records/record_ref.rb
netsuite-0.8.4 lib/netsuite/records/record_ref.rb
netsuite-0.8.3 lib/netsuite/records/record_ref.rb
netsuite-0.8.2 lib/netsuite/records/record_ref.rb
netsuite-0.8.1 lib/netsuite/records/record_ref.rb
netsuite-0.8.0 lib/netsuite/records/record_ref.rb
netsuite-0.7.9 lib/netsuite/records/record_ref.rb
netsuite-0.7.8 lib/netsuite/records/record_ref.rb
netsuite-0.7.7 lib/netsuite/records/record_ref.rb
netsuite-0.7.6 lib/netsuite/records/record_ref.rb
netsuite-0.7.5 lib/netsuite/records/record_ref.rb
netsuite-0.7.4 lib/netsuite/records/record_ref.rb
netsuite-0.7.3 lib/netsuite/records/record_ref.rb
netsuite-0.7.2 lib/netsuite/records/record_ref.rb