Method: NetSuite::Records::CustomFieldList#initialize

Defined in:
lib/netsuite/records/custom_field_list.rb

#initialize(attributes = {}) ⇒ CustomFieldList

Returns a new instance of CustomFieldList.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/netsuite/records/custom_field_list.rb', line 6

def initialize(attributes = {})
  case attributes[:custom_field]
  when Hash
    extract_custom_field(attributes[:custom_field])
  when Array
    attributes[:custom_field].each { |custom_field| extract_custom_field(custom_field) }
  end

  @custom_fields_assoc = Hash.new
  custom_fields.each do |custom_field|
    # not all custom fields have an id; https://github.com/NetSweet/netsuite/issues/182
    if reference_id = custom_field.send(reference_id_type)
      @custom_fields_assoc[reference_id.to_sym] = custom_field
    end
  end
end