Class: Decidim::Votings::Census::Admin::LaunchAccessCodesExport

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

Overview

A command to launch the access codes export

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Command

call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events

Constructor Details

#initialize(dataset, user) ⇒ LaunchAccessCodesExport

Returns a new instance of LaunchAccessCodesExport.



9
10
11
12
# File 'decidim-elections/app/commands/decidim/votings/census/admin/launch_access_codes_export.rb', line 9

def initialize(dataset, user)
  @dataset = dataset
  @user = user
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Decidim::Command

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_export.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_export.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_export.rb', line 19

def call
  return broadcast(:invalid) unless valid?

  UpdateDataset.call(dataset, { status: :exporting_codes }, user)

  ExportAccessCodesJob.perform_later(dataset, user)

  broadcast(:ok)
end