Class: Decidim::System::CreateApiUser

Inherits:
Command
  • Object
show all
Defined in:
decidim-system/app/commands/decidim/system/create_api_user.rb

Instance Method Summary collapse

Methods inherited from Command

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

Constructor Details

#initialize(form, current_admin) ⇒ CreateApiUser

Returns a new instance of CreateApiUser.



6
7
8
9
# File 'decidim-system/app/commands/decidim/system/create_api_user.rb', line 6

def initialize(form, current_admin)
  @form = form
  @current_admin = current_admin
end

Dynamic Method Handling

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

Instance Method Details

#callObject



11
12
13
14
15
16
17
18
19
# File 'decidim-system/app/commands/decidim/system/create_api_user.rb', line 11

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

  transaction do
    create_api_user
  end

  broadcast(:ok, @api_user, @api_secret)
end