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

Inherits:
Command
  • Object
show all
Defined in:
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

Constructor Details

#initialize(dataset, user) ⇒ LaunchAccessCodesExport

Returns a new instance of LaunchAccessCodesExport.



9
10
11
12
# File 'app/commands/decidim/votings/census/admin/launch_access_codes_export.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 '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 '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 '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