Sha256: a45109fe826fe98e4199aceaa2cd9ce4b8bddb46bc9a54d3e5bf8f7d4c62b120

Contents?: true

Size: 963 Bytes

Versions: 1

Compression:

Stored size: 963 Bytes

Contents

# frozen_string_literal: true

require "active_support/concern"

module Decidim
  # This module, when injected into a controller, ensures there's a
  # Participatory Process available and deducts it from the context.
  module NeedsParticipatoryProcess
    extend ActiveSupport::Concern

    include NeedsOrganization

    included do
      after_action :verify_participatory_process
      helper_method :current_participatory_process

      # Public: Finds the current Participatory Process given this controller's
      # context.
      #
      # Returns the current ParticipatoryProcess.
      def current_participatory_process
        @current_participatory_process ||=
          current_organization.participatory_processes.find_by(id: params[:participatory_process_id])
      end

      private

      def verify_participatory_process
        raise ActionController::RoutingError, "Not Found" unless current_participatory_process
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
decidim-core-0.0.1 app/controllers/concerns/decidim/needs_participatory_process.rb