Sha256: 20be57d9bf5b827410bb0bc257b748d814f4aa404f31d9838d0c2f5e1786977f
Contents?: true
Size: 1.13 KB
Versions: 31
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true require "active_support/concern" module Decidim # A concern to include permission to a resource not related with components # od a participatory space. module HasResourcePermission extend ActiveSupport::Concern included do # An association with the permissions settings for the resource has_one :resource_permission, as: :resource, class_name: "Decidim::ResourcePermission" delegate :resource_manifest, :resource_key, to: :class # Public: Whether the permissions for this object actions can be set at resource level. def allow_resource_permissions? false end # Public: Returns permissions for this object actions if they can be set at resource level. def permissions resource_permission&.permissions if allow_resource_permissions? end end class_methods do # Finds the resource manifest for the model. # # Returns a Decidim::ResourceManifest def resource_manifest Decidim.find_resource_manifest(self) end def resource_key model_name.param_key end end end end
Version data entries
31 entries across 31 versions & 1 rubygems