Module: Nurego::APIOperations::Update
- Included in:
- Organization, PaymentMethod
- Defined in:
- lib/nurego/api_operations/update.rb
Instance Method Summary collapse
Instance Method Details
#save ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/nurego/api_operations/update.rb', line 4 def save values = serialize_params(self) if values.length > 0 values.delete(:id) response, api_key = Nurego.request(:post, url, @api_key, values) refresh_from(response, api_key) end self end |
#serialize_params(obj) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/nurego/api_operations/update.rb', line 17 def serialize_params(obj) case obj when nil '' when NuregoObject unsaved_keys = obj.instance_variable_get(:@unsaved_values) obj_values = obj.instance_variable_get(:@values) update_hash = {} unsaved_keys.each do |k| update_hash[k] = serialize_params(obj_values[k]) end update_hash else obj end end |