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.
Class Method Details
.choices4_roles ⇒ Object
Return all defined roles as choices for use in select field.
57 58 59 |
# File 'app/models/dc_policy_role.rb', line 57 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.
64 65 66 67 68 69 70 |
# File 'app/models/dc_policy_role.rb', line 64 def self.get_role(role) if role.class == String rol = role role = find_by(name: rol) || find_by(system_name: rol) end role end |