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
26
27
28
29
30
31
32
33
34
|
# File 'lib/netsuite/records/custom_field_list.rb', line 22
def method_missing(sym, *args, &block)
if @custom_fields_assoc.include?(sym)
return @custom_fields_assoc[sym]
end
if sym.to_s.end_with?('=')
return create_custom_field(sym.to_s[0..-2], args.first)
end
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
36
37
38
39
|
# File 'lib/netsuite/records/custom_field_list.rb', line 36
def respond_to?(sym, include_private = false)
return true if @custom_fields_assoc.include?(sym)
super
end
|
#to_record ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/netsuite/records/custom_field_list.rb', line 41
def to_record
{
"#{record_namespace}:customField" => custom_fields.map do |custom_field|
if custom_field.value.respond_to?(:to_record)
custom_field_value = custom_field.value.to_record
else
custom_field_value = custom_field.value.to_s
end
{
"platformCore:value" => custom_field_value,
'@internalId' => custom_field.internal_id,
'@xsi:type' => custom_field.type
}
end
}
end
|