Class: Decidim::DirectVerifications::Verification::CreateImport

Inherits:
Rectify::Command
  • Object
show all
Defined in:
app/commands/decidim/direct_verifications/verification/create_import.rb

Instance Method Summary collapse

Constructor Details

#initialize(form) ⇒ CreateImport

Returns a new instance of CreateImport.



7
8
9
10
11
12
13
# File 'app/commands/decidim/direct_verifications/verification/create_import.rb', line 7

def initialize(form)
  @form = form
  @file = form.file
  @organization = form.organization
  @user = form.user
  @action = form.action
end

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/commands/decidim/direct_verifications/verification/create_import.rb', line 15

def call
  return broadcast(:invalid) unless form.valid?

  case action
  when :register
    register_users_async
  when :register_and_authorize
    register_users_async
    file.rewind
    authorize_users_async
  when :revoke
    revoke_users_async
  end

  broadcast(:ok)
end