Module: Forem::APIOperations::Update
- Included in:
- Forem::Article, Billboard, Concept, Organization, Page, RecommendedArticlesList, RequestRedirect
- Defined in:
- lib/forem/api_operations/update.rb
Overview
Adds an update class method to any resource that extends this module.
Sends a PUT request to a specific resource URL with the supplied parameters as a JSON body, and returns a new resource instance constructed from the API response.
Instance Method Summary collapse
-
#update(id, params = {}, opts = {}) ⇒ ForemObject
Update an existing resource via the Forem API.
Instance Method Details
#update(id, params = {}, opts = {}) ⇒ ForemObject
Update an existing resource via the Forem API.
Sends a PUT request to {resource_path}/{id} with params
serialised as a JSON body, and returns a new resource instance
reflecting the updated state as returned by the server.
40 41 42 43 44 |
# File 'lib/forem/api_operations/update.rb', line 40 def update(id, params = {}, opts = {}) requestor = opts[:requestor] resp = request(:put, "#{resource_path}/#{id}", params, opts) construct_from(resp.parsed_body, requestor: requestor) end |