Class: Decidim::Votings::Census::Admin::LaunchAccessCodesGeneration

Inherits:
Rectify::Command
  • Object
show all
Defined in:
decidim-elections/app/commands/decidim/votings/census/admin/launch_access_codes_generation.rb

Overview

A command to launch the access codes generation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dataset, user) ⇒ LaunchAccessCodesGeneration

Returns a new instance of LaunchAccessCodesGeneration.


9
10
11
12
# File 'decidim-elections/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

#datasetObject (readonly)

Returns the value of attribute dataset


29
30
31
# File 'decidim-elections/app/commands/decidim/votings/census/admin/launch_access_codes_generation.rb', line 29

def dataset
  @dataset
end

#userObject (readonly)

Returns the value of attribute user


29
30
31
# File 'decidim-elections/app/commands/decidim/votings/census/admin/launch_access_codes_generation.rb', line 29

def user
  @user
end

Instance Method Details

#callObject

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 'decidim-elections/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