Simplify MergedCommentTree#initialize

By setting the comments lazily in a different method, we can share its
code with the parent class.
This commit is contained in:
Javi Martín
2018-08-24 09:03:59 +02:00
parent 14a5ea87a1
commit 7b5ce80593
2 changed files with 7 additions and 8 deletions

View File

@@ -2,14 +2,17 @@ class CommentTree
ROOT_COMMENTS_PER_PAGE = 10
attr_accessor :root_comments, :comments, :commentable, :page, :order
attr_reader :root_comments, :commentable, :page, :order
def initialize(commentable, page, order = "confidence_score", valuations: false)
@commentable = commentable
@page = page
@order = order
@valuations = valuations
@comments = root_comments + root_descendants
end
def comments
@comments ||= root_comments + root_descendants
end
def root_comments