Sha256: 636c837579487d4d54fe80850fbdcae5fe37eee68e66e222a4a79c623db97150
Contents?: true
Size: 888 Bytes
Versions: 13
Compression:
Stored size: 888 Bytes
Contents
# frozen_string_literal: true module Decidim module Budgets # A command with all the business to add remove line items from orders class RemoveLineItem < Rectify::Command # Public: Initializes the command. # # order - The current order for the user # project - The the project to remove from the order def initialize(order, project) @order = order @project = project end # Executes the command. Broadcasts these events: # # - :ok when everything is valid. # - :invalid if the there is an error. # # Returns nothing. def call return broadcast(:invalid) if @order.checked_out? remove_line_item broadcast(:ok, @order) end private def remove_line_item @order.projects.destroy(@project) @order.save! end end end end
Version data entries
13 entries across 13 versions & 2 rubygems