Class: Decidim::User
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::User
- Defined in:
- app/models/decidim/user.rb
Overview
A User is a citizen that wants to join the platform to participate.
Constant Summary collapse
- ROLES =
%w(admin moderator official).freeze
Instance Attribute Summary collapse
-
#invitation_instructions ⇒ Object
Public: Allows customizing the invitation instruction email content when inviting a user.
Instance Method Summary collapse
-
#ability ⇒ Object
Gets the ability instance for the given user.
- #name ⇒ Object
-
#role?(role) ⇒ Boolean
Checks if the user has the given ‘role` or not.
Instance Attribute Details
#invitation_instructions ⇒ Object
Public: Allows customizing the invitation instruction email content when inviting a user.
Returns a String.
30 31 32 |
# File 'app/models/decidim/user.rb', line 30 def invitation_instructions @invitation_instructions end |
Instance Method Details
#ability ⇒ Object
Gets the ability instance for the given user.
35 36 37 |
# File 'app/models/decidim/user.rb', line 35 def ability @ability ||= Ability.new(self) end |
#name ⇒ Object
49 50 51 |
# File 'app/models/decidim/user.rb', line 49 def name super || I18n.t("decidim.anonymous_user") end |
#role?(role) ⇒ Boolean
Checks if the user has the given ‘role` or not.
role - a String or a Symbol that represents the role that is being
checked
Returns a boolean.
45 46 47 |
# File 'app/models/decidim/user.rb', line 45 def role?(role) roles.include?(role.to_s) end |