Module: FruitToLime::ModelHasCustomFields

Included in:
Deal, Organization, Person
Defined in:
lib/fruit_to_lime/model_helpers.rb

Instance Method Summary collapse

Instance Method Details

#set_custom_field(obj) ⇒ Object

Examples:

value = row['business_value_partner_info']
obj.set_custom_field({:integration_id=>"partner_info", :value=>value})


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fruit_to_lime/model_helpers.rb', line 12

def set_custom_field(obj)
    @custom_values = [] if @custom_values == nil
    value = obj[:value]
    field = CustomFieldReference.new(obj)
    custom_value = CustomValue.new
    custom_value.value = value
    custom_value.field = field
    index = @custom_values.find_index do |custom_value|
        custom_value.field.same_as?(field)
    end
    if index
        @custom_values.delete_at index
    end

    @custom_values.push custom_value
    return custom_value
end

#set_custom_value(integration_id, value) ⇒ Object

Examples:

value = row['business_value_partner_info']
obj.set_custom_value("partner_info", value)


6
7
8
# File 'lib/fruit_to_lime/model_helpers.rb', line 6

def set_custom_value(integration_id, value)
    return set_custom_field({integration_id: integration_id, value: value})
end