Class: Forem::Comment

Inherits:
APIResource show all
Extended by:
APIOperations::List, APIOperations::Retrieve
Defined in:
lib/forem/resources/comment.rb

Overview

Represents a comment on a Forem article or podcast episode.

Comments are threaded replies attached to articles or podcast episodes. They can be listed (optionally filtered by the parent content item) or retrieved individually by ID.

Available operations (via mixins):

- +List+     — GET /api/comments  (pass +:a_id+ or +:p_id+ to filter)
- +Retrieve+ — GET /api/comments/:id  (returns comment tree rooted at that ID)

List Parameters

Comments must be filtered by either article or podcast episode:

  • a_id (String) — Article identifier (required if p_id not provided)
  • p_id (String) — Podcast Episode identifier (required if a_id not provided)
  • page (Integer) — Page number
  • per_page (Integer) — Items per page (default: 50)

Returns threaded conversations with nested replies.

Examples:

List all comments for an article

comments = client.comments.list(a_id: "some-article-id")
comments.data.each { |c| puts c.body_html }

List comments for a podcast episode

comments = client.comments.list(p_id: "some-podcast-id")
comments.data.each { |c| puts c.body_html }

Retrieve a comment tree by root comment ID

comment = client.comments.retrieve("abc123")
puts comment.body_html

See Also:

Constant Summary collapse

OBJECT_NAME =
"comment"
RESOURCE_PATH =
"/api/comments"

Instance Attribute Summary

Attributes inherited from ForemObject

#requestor

Method Summary

Methods included from APIOperations::List

list

Methods included from APIOperations::Retrieve

retrieve

Methods inherited from APIResource

#refresh, resource_path, #resource_url

Methods inherited from ForemObject

#==, #[], #[]=, construct_from, cursor_list, #initialize, #inspect, #method_missing, paginated_list, #respond_to_missing?, #to_hash

Methods included from APIOperations::Request

included, #request

Constructor Details

This class inherits a constructor from Forem::ForemObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Forem::ForemObject