Class: Decidim::DecidimAwesome::Admin::DestroyConstraint

Inherits:
Rectify::Command
  • Object
show all
Defined in:
app/commands/decidim/decidim_awesome/admin/destroy_constraint.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(constraint) ⇒ DestroyConstraint

Public: Initializes the command.

constraint - A constraint constraint



10
11
12
# File 'app/commands/decidim/decidim_awesome/admin/destroy_constraint.rb', line 10

def initialize(constraint)
  @constraint = constraint
end

Instance Attribute Details

#constraintObject (readonly)

Returns the value of attribute constraint.



27
28
29
# File 'app/commands/decidim/decidim_awesome/admin/destroy_constraint.rb', line 27

def constraint
  @constraint
end

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid.

  • :invalid if we couldn’t proceed.

Returns nothing.



20
21
22
23
24
25
# File 'app/commands/decidim/decidim_awesome/admin/destroy_constraint.rb', line 20

def call
  constraint.destroy!
  broadcast(:ok)
rescue StandardError => e
  broadcast(:invalid, e.message)
end