Sha256: 94aa0ccd4d5b56df299020905bcf68e01b5f57a4832a9466960df045ab7915cf
Contents?: true
Size: 1.13 KB
Versions: 4
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true module Decidim # This class infers the current participatory process we're scoped to by # looking at the request parameters and the organization in the request # environment, and injects it into the environment. class CurrentParticipatoryProcess # Public: Matches the request against a participatory process and injects it # into the environment. # # request - The request that holds the participatory process relevant # information. # # Returns a true if the request matched, false otherwise def matches?(request) env = request.env @organization = env["decidim.current_organization"] return false unless @organization current_participatory_process(env, request.params) ? true : false end private def current_participatory_process(env, params) env["decidim.current_participatory_process"] ||= detect_current_participatory_process(params) end def detect_current_participatory_process(params) @organization.participatory_processes.find_by_id(params["participatory_process_id"]) end end end
Version data entries
4 entries across 4 versions & 1 rubygems