Class: InsalesApi::ProductFieldValue
- Inherits:
-
Base
- Object
- ActiveResource::Base
- Base
- InsalesApi::ProductFieldValue
show all
- Defined in:
- lib/insales_api/product_field_value.rb
Class Method Summary
collapse
Methods inherited from Base
configure, dump_config, for_account, restore_config
#count
#find_each, #find_in_batches
Class Method Details
.create_or_update(params) ⇒ Object
12
13
14
15
16
17
18
19
|
# File 'lib/insales_api/product_field_value.rb', line 12
def create_or_update(params)
if (value = find_by_field_id(params))
value.update_attribute(:value, params[:value])
value
else
create(params)
end
end
|
.find_by_field_id(params) ⇒ Object
6
7
8
9
10
|
# File 'lib/insales_api/product_field_value.rb', line 6
def find_by_field_id(params)
field_id = params[:product_field_id]
all(params: { product_id: params[:product_id] })
.find { |x| x.product_field_id == field_id }
end
|