Module: Hawkei::APIOperation::Save
Overview
Save (create or update) a resource for the API
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#save(params = {}, options = {}) ⇒ Hawkei::Object
(also: #update)
Create or Update an API Resource.
Class Method Details
.included(base) ⇒ Object
51 52 53 |
# File 'lib/hawkei/api_operation/save.rb', line 51 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#save(params = {}, options = {}) ⇒ Hawkei::Object Also known as: update
Create or Update an API Resource
42 43 44 45 46 47 48 |
# File 'lib/hawkei/api_operation/save.rb', line 42 def save(params = {}, = {}) path = singleton_methods.include?(:id) ? "#{resource_path}/#{id}" : resource_path method = singleton_methods.include?(:id) ? :put : :post response = request(method, path, to_hash.merge(params), ) update_from(response) end |