Class: NetSuite::Records::CustomFieldList
Instance Method Summary
collapse
#record_namespace
Constructor Details
#initialize(attributes = {}) ⇒ CustomFieldList
Returns a new instance of CustomFieldList.
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/netsuite/records/custom_field_list.rb', line 6
def initialize(attributes = {})
case attributes[:custom_field]
when Hash
(attributes[:custom_field])
when Array
attributes[:custom_field].each { |custom_field| (custom_field) }
end
@custom_fields_assoc = Hash.new
custom_fields.each { |custom_field| @custom_fields_assoc[custom_field.internal_id.to_sym] = custom_field }
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
22
23
24
25
|
# File 'lib/netsuite/records/custom_field_list.rb', line 22
def method_missing(sym, *args, &block)
return @custom_fields_assoc[sym] if @custom_fields_assoc.include? sym
super(sym, *args, &block)
end
|
Instance Method Details
#custom_fields ⇒ Object
18
19
20
|
# File 'lib/netsuite/records/custom_field_list.rb', line 18
def custom_fields
@custom_fields ||= []
end
|
#respond_to?(sym, include_private = false) ⇒ Boolean
27
28
29
30
|
# File 'lib/netsuite/records/custom_field_list.rb', line 27
def respond_to?(sym, include_private = false)
return true if @custom_fields_assoc.include? sym
super
end
|
#to_record ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/netsuite/records/custom_field_list.rb', line 32
def to_record
{
"#{record_namespace}:customField" => custom_fields.map(&:to_record),
:attributes! => {
"#{record_namespace}:customField" => {
'internalId' => custom_fields.map(&:internal_id),
'xsi:type' => custom_fields.map(&:type)
}
}
}
end
|