Class: Decidim::Admin::UpdateOrganizationTosVersion
- Inherits:
-
Command
- Object
- Command
- Decidim::Admin::UpdateOrganizationTosVersion
- Defined in:
- app/commands/decidim/admin/update_organization_tos_version.rb
Overview
A command with the business logic for updating the current organization tos_version attribute.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(organization, page, form) ⇒ UpdateOrganizationTosVersion
constructor
Public: Initializes the command.
Constructor Details
#initialize(organization, page, form) ⇒ UpdateOrganizationTosVersion
Public: Initializes the command.
organization - The Organization that will be updated. page - A static_page instance (slug = “terms-of-service”). form - A form object with the params.
13 14 15 16 17 |
# File 'app/commands/decidim/admin/update_organization_tos_version.rb', line 13 def initialize(organization, page, form) @organization = organization @page = page @form = form end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid.
-
:invalid if the form was not valid or not the TOS page.
Returns nothing.
25 26 27 28 29 30 31 32 |
# File 'app/commands/decidim/admin/update_organization_tos_version.rb', line 25 def call return broadcast(:invalid) if @form.nil? return broadcast(:invalid) if @page.nil? return broadcast(:invalid) unless @page.slug == "terms-of-service" update_organization_tos_version broadcast(:ok) end |