Sha256: b468c51e18ccb3e6312b0196219320ea76e3c8f99e1c363f804a77f4d40d8cb5
Contents?: true
Size: 857 Bytes
Versions: 10
Compression:
Stored size: 857 Bytes
Contents
module Nurego module APIOperations module Update 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 def serialize_params(obj, force = false) case obj when nil '' when NuregoObject unsaved_keys = force ? obj.instance_variable_get(:@values).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], true) end update_hash else obj end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems