Class: Decidim::Lausanne::Budgets::AddLineItem
- Defined in:
- app/commands/decidim/lausanne/budgets/add_line_item.rb
Overview
A command with all the business to add new line items to orders
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(current_order, project, current_user) ⇒ AddLineItem
constructor
Public: Initializes the command.
Constructor Details
#initialize(current_order, project, current_user) ⇒ AddLineItem
Public: Initializes the command.
order - The current order for the user or nil if it is not created yet. project - The the project to include in the order current_user - The current user logged in
13 14 15 16 17 |
# File 'app/commands/decidim/lausanne/budgets/add_line_item.rb', line 13 def initialize(current_order, project, current_user) @order = current_order @project = project @current_user = current_user end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid.
-
:invalid if the there is an error.
Returns nothing.
25 26 27 28 29 30 31 32 |
# File 'app/commands/decidim/lausanne/budgets/add_line_item.rb', line 25 def call transaction do return broadcast(:invalid) if voting_not_enabled? || order.checked_out? add_line_item broadcast(:ok, order) end end |