Sha256: b9c8fcfe74675fe67118959962056fb22915d46249a427daceae2aeb81723a5a

Contents?: true

Size: 914 Bytes

Versions: 2

Compression:

Stored size: 914 Bytes

Contents

module NetSuite
  module Records
    class CustomField
      include Support::Fields
      include Support::Records

      attr_reader :internal_id, :type

      def initialize(attributes = {})
        @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
        @type        = attributes.delete(:type) || attributes.delete(:"@xsi:type")
        @type        = @type.split(':').last if @type
        self.attributes = attributes
      end

      def to_record
        hash_rec = attributes.inject({}) do |hash, (k,v)|
          kname = "#{record_namespace}:#{k.to_s.lower_camelcase}"
          v = v.to_record if v.respond_to?(:to_record)
          hash[kname] = v
          hash
        end
        hash_rec["#{record_namespace}:internalId"] = internal_id if internal_id
        hash_rec["#{record_namespace}:type"]       = type if type
        hash_rec
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
netsuite-0.0.16 lib/netsuite/records/custom_field.rb
netsuite-0.0.15 lib/netsuite/records/custom_field.rb