lib/redd/models/more_comments.rb in redd-0.8.8 vs lib/redd/models/more_comments.rb in redd-0.9.0.pre.1

- old
+ new

@@ -1,22 +1,22 @@ # frozen_string_literal: true -require_relative 'basic_model' +require_relative 'model' module Redd module Models # An object that represents a bunch of comments that need to be expanded. - class MoreComments < BasicModel + class MoreComments < Model # Expand the object's children into a listing of Comments and MoreComments. # @param link [Submission] the submission the object belongs to # @param sort [String] the sort order of the submission # @return [Listing<Comment, MoreComments>] the expanded children def expand(link:, sort: nil) - params = { link_id: link.name, children: get_attribute(:children).join(',') } + params = { link_id: link.name, children: read_attribute(:children).join(',') } params[:sort] = sort if sort params[:sort] = link.sort_order if link.sort_order - @client.model(:get, '/api/morechildren', params) + client.model(:get, '/api/morechildren', params) end # Keep expanding until all top-level MoreComments are converted to comments. # @param link [Submission] the object's submission # @param sort [String] the sort order of the returned comments @@ -42,10 +42,34 @@ end end # @return [Array<String>] an array representation of self def to_ary - get_attribute(:children) + read_attribute(:children) end + + # @!attribute [r] count + # @return [Integer] the comments under this object + property :count + + # @!attribute [r] name + # @return [String] the object fullname + property :name + + # @!attribute [r] id + # @return [String] the object id + property :id + + # @!attribute [r] parent_id + # @return [String] the parent fullname + property :parent_id + + # @!attribute [r] depth + # @return [Integer] the depth + property :depth + + # @!attribute [r] children + # @return [Array<String>] the unexpanded comments + property :children end end end