Module: Forem::APIOperations::Retrieve
- Included in:
- Forem::AdminConcept, Forem::AgentSession, Forem::Article, Billboard, Comment, Organization, Page, RecommendedArticlesList, RequestRedirect, Segment, Survey, Trend, User
- Defined in:
- lib/forem/api_operations/retrieve.rb
Overview
Adds a retrieve class method to any resource that extends this module.
Fetches a single resource by its ID with a GET request and returns a resource instance populated from the API response.
Instance Method Summary collapse
-
#retrieve(id, opts = {}) ⇒ ForemObject
Retrieve a single resource by its ID from the Forem API.
Instance Method Details
#retrieve(id, opts = {}) ⇒ ForemObject
Retrieve a single resource by its ID from the Forem API.
Sends a GET request to {resource_path}/{id} and constructs
a resource instance from the response body.
36 37 38 39 40 |
# File 'lib/forem/api_operations/retrieve.rb', line 36 def retrieve(id, opts = {}) requestor = opts[:requestor] resp = request(:get, "#{resource_path}/#{id}", {}, opts) construct_from(resp.parsed_body, requestor: requestor) end |