Class: DcPolicyRole
- Inherits:
-
Object
- Object
- DcPolicyRole
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- app/models/dc_policy_role.rb
Overview
Schema information
Collection name: dc_policy_role : User roles
_id BSON::ObjectId _id
created_at Time created_at
updated_at Time updated_at
name String Role name
system_name String System role name if required by application
active Mongoid::Boolean Role is active
Documents in this model define all available user roles in the application. Roles are defined by unique name which is valid for current application or as alternative name (system_name) which can be persistent, when application is used as Rails plugin.
Class Method Summary collapse
-
.choices4_roles ⇒ Object
Return all defined roles as choices for use in select field.
-
.get_role(role) ⇒ Object
Search for role when role parameter is String.
Instance Method Summary collapse
-
#cache_clear ⇒ Object
Clear cache if cache is configured.
Class Method Details
.choices4_roles ⇒ Object
Return all defined roles as choices for use in select field.
68 69 70 |
# File 'app/models/dc_policy_role.rb', line 68 def self.choices4_roles where(active: true).order_by(name: 1).inject([]) { |r,role| r << [ role.name, role._id] } end |
.get_role(role) ⇒ Object
Search for role when role parameter is String.
75 76 77 78 79 80 81 |
# File 'app/models/dc_policy_role.rb', line 75 def self.get_role(role) if role.class == String rol = role role = find_by(name: rol) || find_by(system_name: rol) end role end |
Instance Method Details
#cache_clear ⇒ Object
Clear cache if cache is configured
60 61 62 63 |
# File 'app/models/dc_policy_role.rb', line 60 def cache_clear DrgCms.cache_clear(:dc_permission) DrgCms.cache_clear(:dc_site) end |