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.7.1 lib/netsuite/records/record_ref.rb
netsuite-0.7.0 lib/netsuite/records/record_ref.rb
netsuite-0.6.9 lib/netsuite/records/record_ref.rb
netsuite-0.6.8 lib/netsuite/records/record_ref.rb
netsuite-0.6.7 lib/netsuite/records/record_ref.rb
netsuite-0.6.6 lib/netsuite/records/record_ref.rb
netsuite-0.6.5 lib/netsuite/records/record_ref.rb
netsuite-0.6.4 lib/netsuite/records/record_ref.rb
netsuite-0.6.3 lib/netsuite/records/record_ref.rb
netsuite-0.6.2 lib/netsuite/records/record_ref.rb
netsuite-0.6.1 lib/netsuite/records/record_ref.rb
netsuite-0.6.0 lib/netsuite/records/record_ref.rb
netsuite-0.5.9 lib/netsuite/records/record_ref.rb
netsuite-0.5.8 lib/netsuite/records/record_ref.rb
netsuite-0.5.7 lib/netsuite/records/record_ref.rb
netsuite-0.5.6 lib/netsuite/records/record_ref.rb
netsuite-0.5.5 lib/netsuite/records/record_ref.rb
netsuite-0.5.4 lib/netsuite/records/record_ref.rb
netsuite-0.5.3 lib/netsuite/records/record_ref.rb
netsuite-0.5.2 lib/netsuite/records/record_ref.rb