Module: ActiveRecordPermissions
- Defined in:
- lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_record_permissions.rb
Overview
This module attempts to create permissions conventions for your ActiveRecord models. It supports english-based methods that let you restrict access per-model, per-record, per-column, per-action, and per-user. All at once.
You may define instance methods in the following formats:
def #{column}_authorized_for_#{action}?
def #{column}_authorized?
def authorized_for_#{action}?
Your methods should allow for the following special cases:
* cron scripts
* guest users (or nil current_user objects)
Defined Under Namespace
Modules: ModelUserAccess, Permissions
Constant Summary collapse
- @@current_user_method =
:current_user
- @@default_permission =
true
- @@allowed_actions =
[:create, :read, :update, :destroy, :print]
Class Method Summary collapse
- .allowed_actions ⇒ Object
-
.allowed_actions=(v) ⇒ Object
AST Begin Actions allowed.
- .current_user_method ⇒ Object
-
.current_user_method=(v) ⇒ Object
ActiveRecordPermissions needs to know what method on your ApplicationController will return the current user, if available.
- .default_permission ⇒ Object
-
.default_permission=(v) ⇒ Object
Whether the default permission is permissive or not If set to true, then everything’s allowed until configured otherwise.
Class Method Details
.allowed_actions ⇒ Object
29 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_record_permissions.rb', line 29 def self.allowed_actions; @@allowed_actions; end |
.allowed_actions=(v) ⇒ Object
AST Begin Actions allowed. If you create a customized action add it to this list.
28 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_record_permissions.rb', line 28 def self.allowed_actions=(v); @@allowed_actions = v; end |
.current_user_method ⇒ Object
17 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_record_permissions.rb', line 17 def self.current_user_method; @@current_user_method; end |
.current_user_method=(v) ⇒ Object
ActiveRecordPermissions needs to know what method on your ApplicationController will return the current user, if available. This defaults to the :current_user method. You may configure this in your environment.rb if you have a different setup.
16 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_record_permissions.rb', line 16 def self.current_user_method=(v); @@current_user_method = v; end |
.default_permission ⇒ Object
23 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_record_permissions.rb', line 23 def self.; @@default_permission; end |
.default_permission=(v) ⇒ Object
Whether the default permission is permissive or not If set to true, then everything’s allowed until configured otherwise
22 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_record_permissions.rb', line 22 def self.(v); @@default_permission = v; end |