Class: Decidim::User

Inherits:
ApplicationRecord show all
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

Instance Method Summary collapse

Instance Attribute Details

#invitation_instructionsObject

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

#abilityObject

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

#nameObject



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.

Returns:

  • (Boolean)


45
46
47
# File 'app/models/decidim/user.rb', line 45

def role?(role)
  roles.include?(role.to_s)
end