Sha256: 16d37f996866a5028148be962b1bcc297fb335bc5600f0fe41439b0e19fc6a70
Contents?: true
Size: 1.29 KB
Versions: 11
Compression:
Stored size: 1.29 KB
Contents
# frozen_string_literal: true module Decidim module Assemblies # This class infers the current assembly we're scoped to by # looking at the request parameters and the organization in the request # environment, and injects it into the environment. class CurrentAssembly # Public: Matches the request against an assembly and injects it # into the environment. # # request - The request that holds the assembly 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_assembly(env, request.params) ? true : false end private def current_assembly(env, params) env["decidim.current_participatory_space"] ||= detect_current_assembly(params) end def detect_current_assembly(params) organization_assemblies.where(slug: params["assembly_slug"]).or( organization_assemblies.where(id: params["assembly_id"]) ).first! end def organization_assemblies @organization_assemblies ||= OrganizationAssemblies.new(@organization).query end end end end
Version data entries
11 entries across 11 versions & 1 rubygems