Class: Thredded::NullUser

Overview

A Thredded::NullUser stands in place of a real (mainapp supplied) User when:

  • user is not logged in (ie. the thredded_current_user)

  • a user that was hard-deleted (e.g. if a post was made by a user, and then that user is destroyed, the post’s user ID is nullified).

Instance Method Summary collapse

Methods included from UserPermissions::Admin::None

#thredded_admin?

Methods included from UserPermissions::Moderate::None

#thredded_can_moderate_messageboard?, #thredded_can_moderate_messageboards

Methods included from UserPermissions::Message::ReadersOfWriteableBoards

#thredded_can_message_users

Methods included from UserPermissions::Write::None

#thredded_can_write_messageboards

Methods included from UserPermissions::Read::All

#thredded_can_read_messageboard?, #thredded_can_read_messageboards

Instance Method Details

#idObject



20
21
22
# File 'app/models/thredded/null_user.rb', line 20

def id
  nil
end

#nameObject



24
25
26
# File 'app/models/thredded/null_user.rb', line 24

def name
  I18n.t('thredded.null_user_name')
end

#thredded_anonymous?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'app/models/thredded/null_user.rb', line 36

def thredded_anonymous?
  true
end

#thredded_display_nameObject



48
49
50
# File 'app/models/thredded/null_user.rb', line 48

def thredded_display_name
  to_s
end

#thredded_private_topicsObject



16
17
18
# File 'app/models/thredded/null_user.rb', line 16

def thredded_private_topics
  Thredded::PrivateTopic.none
end

#thredded_user_detailObject



40
41
42
# File 'app/models/thredded/null_user.rb', line 40

def thredded_user_detail
  Thredded::UserDetail.new
end

#thredded_user_preferenceObject



44
45
46
# File 'app/models/thredded/null_user.rb', line 44

def thredded_user_preference
  Thredded::UserPreference.new
end

#to_sObject



28
29
30
# File 'app/models/thredded/null_user.rb', line 28

def to_s
  name
end

#valid?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'app/models/thredded/null_user.rb', line 32

def valid?
  false
end