Class: Decidim::DecidimAwesome::Admin::DestroyCookieCategory
- Inherits:
-
Command
- Object
- Command
- Decidim::DecidimAwesome::Admin::DestroyCookieCategory
- Includes:
- NeedsAwesomeConfig
- Defined in:
- app/commands/decidim/decidim_awesome/admin/destroy_cookie_category.rb
Instance Attribute Summary collapse
-
#category_slug ⇒ Object
readonly
Returns the value of attribute category_slug.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#organization ⇒ Object
readonly
Returns the value of attribute organization.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(category_slug, organization) ⇒ DestroyCookieCategory
constructor
Public: Initializes the command.
Methods included from NeedsAwesomeConfig
Constructor Details
#initialize(category_slug, organization) ⇒ DestroyCookieCategory
Public: Initializes the command.
category_slug - The slug of the category to destroy. organization - The organization where the category belongs. config - The AwesomeConfig instance for cookie management.
14 15 16 17 18 |
# File 'app/commands/decidim/decidim_awesome/admin/destroy_cookie_category.rb', line 14 def initialize(category_slug, organization) @category_slug = category_slug @organization = organization @config = AwesomeConfig.find_by(organization: organization, var: :cookie_management) end |
Instance Attribute Details
#category_slug ⇒ Object (readonly)
Returns the value of attribute category_slug.
20 21 22 |
# File 'app/commands/decidim/decidim_awesome/admin/destroy_cookie_category.rb', line 20 def category_slug @category_slug end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
20 21 22 |
# File 'app/commands/decidim/decidim_awesome/admin/destroy_cookie_category.rb', line 20 def config @config end |
#organization ⇒ Object (readonly)
Returns the value of attribute organization.
20 21 22 |
# File 'app/commands/decidim/decidim_awesome/admin/destroy_cookie_category.rb', line 20 def organization @organization end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid.
-
:invalid if the category is not found.
Returns nothing.
28 29 30 31 32 33 34 35 36 37 |
# File 'app/commands/decidim/decidim_awesome/admin/destroy_cookie_category.rb', line 28 def call return broadcast(:invalid) unless config&.value config.value.delete(category_slug) config.save! broadcast(:ok) rescue StandardError => e broadcast(:invalid, e.) end |