Class: Decidim::AuthorizeUser
- Inherits:
-
Rectify::Command
- Object
- Rectify::Command
- Decidim::AuthorizeUser
- Defined in:
- app/commands/decidim/authorize_user.rb
Overview
A command to authorize a user with an authorization handler.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(handler) ⇒ AuthorizeUser
constructor
Public: Initializes the command.
Constructor Details
#initialize(handler) ⇒ AuthorizeUser
Public: Initializes the command.
handler - An AuthorizationHandler object.
9 10 11 |
# File 'app/commands/decidim/authorize_user.rb', line 9 def initialize(handler) @handler = handler end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid.
-
:invalid if the handler wasn’t valid and we couldn’t proceed.
Returns nothing.
19 20 21 22 23 24 |
# File 'app/commands/decidim/authorize_user.rb', line 19 def call return broadcast(:invalid) unless handler.valid? && unique? broadcast(:ok) end |