Class: Decidim::System::UpdateOAuthApplication
- Inherits:
-
Command
- Object
- Command
- Decidim::System::UpdateOAuthApplication
- Defined in:
- app/commands/decidim/system/update_oauth_application.rb
Overview
Updates the OAuth application given form data.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(application, form, user) ⇒ UpdateOAuthApplication
constructor
Initializes the command.
- #oauth_application_attributes ⇒ Object
Constructor Details
#initialize(application, form, user) ⇒ UpdateOAuthApplication
Initializes the command.
application - The OAuthApplication to update. form - The form object containing the data to update. user - The user that updates the application.
12 13 14 15 16 |
# File 'app/commands/decidim/system/update_oauth_application.rb', line 12 def initialize(application, form, user) @application = application @form = form @user = user end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/commands/decidim/system/update_oauth_application.rb', line 18 def call return broadcast(:invalid) unless @form.valid? @application = Decidim.traceability.update!( @application, @user, **oauth_application_attributes ) broadcast(:ok, @application) rescue ActiveRecord::RecordInvalid @form.errors.add(:organization_logo, @application.errors[:organization_logo]) if @application.errors.include? :organization_logo broadcast(:invalid) end |
#oauth_application_attributes ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/commands/decidim/system/update_oauth_application.rb', line 33 def oauth_application_attributes { name: @form.name, decidim_organization_id: @form.decidim_organization_id, organization_name: @form.organization_name, organization_url: @form.organization_url, redirect_uri: @form.redirect_uri }.tap do |attrs| attrs[:organization_logo] = @form.organization_logo if @form.organization_logo.present? end end |