module Hawkei::APIOperation::Save

Save (create or update) a resource for the API

Public Class Methods

included(base) click to toggle source
# File lib/hawkei/api_operation/save.rb, line 51
def self.included(base)
  base.extend(ClassMethods)
end

Public Instance Methods

save(params = {}, options = {}) click to toggle source

Create or Update an API Resource

@param [Hash] params for the request @param [Hash] Additional options for the request

@return [Hawkei::Object] response from the API

# File lib/hawkei/api_operation/save.rb, line 42
def save(params = {}, options = {})
  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), options)
  update_from(response)
end
Also aliased as: update
update(params = {}, options = {})
Alias for: save