Class: Decidim::DefaultPermissions
- Inherits:
-
Object
- Object
- Decidim::DefaultPermissions
- Includes:
- UserRoleChecker
- Defined in:
- app/permissions/decidim/default_permissions.rb
Overview
Default permissions class for all components and spaces. It deauthorizes all actions by any kind of user. Also works as a default implementation so other components can inherit from it and get some convenience methods. Delegates the admin permission check on :subject and :action to the permissions of each module.
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(user, permission_action, context = {}) ⇒ DefaultPermissions
constructor
A new instance of DefaultPermissions.
- #permissions ⇒ Object
Constructor Details
#initialize(user, permission_action, context = {}) ⇒ DefaultPermissions
Returns a new instance of DefaultPermissions.
11 12 13 14 15 |
# File 'app/permissions/decidim/default_permissions.rb', line 11 def initialize(user, , context = {}) @user = user @permission_action = @context = context end |
Instance Method Details
#permissions ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'app/permissions/decidim/default_permissions.rb', line 17 def return if .scope != target_scope return unless subject == target_subject = "can_#{action}?" toggle_allow(send()) if respond_to?(, true) end |