Class: Decidim::Votings::Census::Admin::LaunchAccessCodesGeneration
- Inherits:
-
Command
- Object
- Command
- Decidim::Votings::Census::Admin::LaunchAccessCodesGeneration
- Defined in:
- app/commands/decidim/votings/census/admin/launch_access_codes_generation.rb
Overview
A command to launch the access codes generation
Instance Attribute Summary collapse
-
#dataset ⇒ Object
readonly
Returns the value of attribute dataset.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(dataset, user) ⇒ LaunchAccessCodesGeneration
constructor
A new instance of LaunchAccessCodesGeneration.
Constructor Details
#initialize(dataset, user) ⇒ LaunchAccessCodesGeneration
Returns a new instance of LaunchAccessCodesGeneration.
9 10 11 12 |
# File 'app/commands/decidim/votings/census/admin/launch_access_codes_generation.rb', line 9 def initialize(dataset, user) @dataset = dataset @user = user end |
Instance Attribute Details
#dataset ⇒ Object (readonly)
Returns the value of attribute dataset.
29 30 31 |
# File 'app/commands/decidim/votings/census/admin/launch_access_codes_generation.rb', line 29 def dataset @dataset end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
29 30 31 |
# File 'app/commands/decidim/votings/census/admin/launch_access_codes_generation.rb', line 29 def user @user end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcast this events:
-
:ok when everything is valid
-
:invalid when the user is not present
Returns nothing.
19 20 21 22 23 24 25 26 27 |
# File 'app/commands/decidim/votings/census/admin/launch_access_codes_generation.rb', line 19 def call return broadcast(:invalid) unless valid? update_dataset_status(dataset, :generating_codes, user) GenerateAccessCodesJob.perform_later(dataset, user) broadcast(:ok) end |