Sha256: a500f113129f1d22f968187d9b26b91a9f2df3b97d8f749b4e0dc55a7ad2bf54
Contents?: true
Size: 1.28 KB
Versions: 18
Compression:
Stored size: 1.28 KB
Contents
# frozen_string_literal: true module Decidim module Assemblies # This module, when injected into a controller, ensures there's a # Assembly available and deducts it from the context. module NeedsAssembly def self.enhance_controller(instance_or_module) instance_or_module.class_eval do helper_method :current_assembly end end def self.extended(base) base.extend Decidim::NeedsOrganization, InstanceMethods enhance_controller(base) end def self.included(base) base.include Decidim::NeedsOrganization, InstanceMethods enhance_controller(base) end module InstanceMethods # Public: Finds the current Assembly given this controller's # context. # # Returns the current Assembly. def current_assembly @current_assembly ||= detect_assembly end alias current_participatory_space current_assembly private def ability_context super.merge(current_assembly: current_assembly) end def detect_assembly request.env["current_assembly"] || OrganizationAssemblies.new(current_organization).query.find(params[:assembly_id] || params[:id]) end end end end end
Version data entries
18 entries across 18 versions & 2 rubygems