Sha256: 51b25bf063804aada1508821f6cb17455906a930d8a2802f9c8386773541566e

Contents?: true

Size: 896 Bytes

Versions: 29

Compression:

Stored size: 896 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 < Decidim::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

      attr_reader :project

      def remove_line_item
        @order.projects.destroy(project)
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
decidim-budgets-0.30.0.rc2 app/commands/decidim/budgets/remove_line_item.rb
decidim-budgets-0.30.0.rc1 app/commands/decidim/budgets/remove_line_item.rb
decidim-budgets-0.29.2 app/commands/decidim/budgets/remove_line_item.rb
decidim-budgets-0.28.5 app/commands/decidim/budgets/remove_line_item.rb
decidim-budgets-0.29.1 app/commands/decidim/budgets/remove_line_item.rb
decidim-budgets-0.28.4 app/commands/decidim/budgets/remove_line_item.rb
decidim-budgets-0.27.9 app/commands/decidim/budgets/remove_line_item.rb
decidim-budgets-0.29.0 app/commands/decidim/budgets/remove_line_item.rb
decidim-budgets-0.28.3 app/commands/decidim/budgets/remove_line_item.rb
decidim-budgets-0.27.8 app/commands/decidim/budgets/remove_line_item.rb
decidim-budgets-0.29.0.rc4 app/commands/decidim/budgets/remove_line_item.rb
decidim-budgets-0.29.0.rc3 app/commands/decidim/budgets/remove_line_item.rb
decidim-budgets-0.29.0.rc2 app/commands/decidim/budgets/remove_line_item.rb
decidim-budgets-0.29.0.rc1 app/commands/decidim/budgets/remove_line_item.rb
decidim-budgets-0.28.2 app/commands/decidim/budgets/remove_line_item.rb
decidim-budgets-0.27.7 app/commands/decidim/budgets/remove_line_item.rb
decidim-budgets-0.28.1 app/commands/decidim/budgets/remove_line_item.rb
decidim-budgets-0.27.6 app/commands/decidim/budgets/remove_line_item.rb
decidim-budgets-0.28.0 app/commands/decidim/budgets/remove_line_item.rb
decidim-budgets-0.27.5 app/commands/decidim/budgets/remove_line_item.rb