Class: Decidim::System::RefreshApiUserSecret

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

Instance Method Summary collapse

Methods inherited from Command

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

Constructor Details

#initialize(api_user, current_admin) ⇒ RefreshApiUserSecret

Returns a new instance of RefreshApiUserSecret.



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

def initialize(api_user, current_admin)
  @api_user = api_user
  @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
20
# File 'decidim-system/app/commands/decidim/system/refresh_api_user_secret.rb', line 11

def call
  return broadcast(:invalid) if @api_user.blank?
  return broadcast(:invalid) if @current_admin.blank?

  transaction do
    refresh_secret
  end

  broadcast(:ok, @api_secret)
end