Class: Reviewable::Conversation

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Serialization
Defined in:
lib/reviewable/conversation.rb

Defined Under Namespace

Classes: Post

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(meta_topic) ⇒ Conversation

Returns a new instance of Conversation.



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/reviewable/conversation.rb', line 30

def initialize(meta_topic)
  @id = meta_topic.id
  @has_more = false
  @permalink = "#{Discourse.base_url_no_prefix}#{meta_topic.relative_url}"
  @posts = []

  meta_posts = meta_topic.ordered_posts.where(post_type: ::Post.types[:regular]).limit(2)

  @conversation_posts = meta_posts.map { |mp| Reviewable::Conversation::Post.new(mp) }
  @has_more = meta_topic.posts_count > 2
end

Instance Attribute Details

#conversation_postsObject (readonly)

Returns the value of attribute conversation_posts.



28
29
30
# File 'lib/reviewable/conversation.rb', line 28

def conversation_posts
  @conversation_posts
end

#has_moreObject (readonly)

Returns the value of attribute has_more.



28
29
30
# File 'lib/reviewable/conversation.rb', line 28

def has_more
  @has_more
end

#idObject (readonly)

Returns the value of attribute id.



28
29
30
# File 'lib/reviewable/conversation.rb', line 28

def id
  @id
end

Returns the value of attribute permalink.



28
29
30
# File 'lib/reviewable/conversation.rb', line 28

def permalink
  @permalink
end