Class: Thredded::PrivatePost

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
PostCommon
Defined in:
app/models/thredded/private_post.rb

Instance Method Summary collapse

Methods included from PostCommon

#avatar_url, #calculate_page, #filtered_content, #first_post_in_topic?, #mark_as_unread, #previous_post, #readers_from_user_names

Instance Method Details

#page(per_page: self.class.default_per_page) ⇒ Object

Parameters:

  • per_page (Integer) (defaults to: self.class.default_per_page)


25
26
27
# File 'app/models/thredded/private_post.rb', line 25

def page(per_page: self.class.default_per_page)
  calculate_page(postable.posts, per_page)
end

#private_topic_post?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'app/models/thredded/private_post.rb', line 29

def private_topic_post?
  true
end

#readersActiveRecord::Relation<Thredded.user_class>

Returns users that can read this post.

Returns:



34
35
36
37
38
39
40
41
# File 'app/models/thredded/private_post.rb', line 34

def readers
  collection_proxy = postable.users
  if persisted?
    collection_proxy.scope
  else
    Thredded.user_class.where(id: collection_proxy.to_a.map(&:id))
  end
end