Module: Access::Role::Base
- Defined in:
- lib/access/role.rb
Overview
The module to extend the Database manager
Instance Method Summary collapse
-
#create(role, description = nil, privileges = []) ⇒ Object
Create a new Role role is a role-id, should be w+ description is a piece of text describing the role privileges are the privileges the role provides.
-
#load(*args) ⇒ Object
Restore an Access::Privilege from it’s storable data.
Instance Method Details
#create(role, description = nil, privileges = []) ⇒ Object
Create a new Role role is a role-id, should be w+ description is a piece of text describing the role privileges are the privileges the role provides
23 24 25 26 27 28 29 30 |
# File 'lib/access/role.rb', line 23 def create(role, description=nil, privileges=[]) raise "Role #{role} already exists" if exists?(role) role = Role.new(role, description) role.access = access role.base = self add(role) role end |
#load(*args) ⇒ Object
Restore an Access::Privilege from it’s storable data
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/access/role.rb', line 33 def load(*args) # :nodoc: return nil unless data = super roles = access.role data[:roles] = data[:roles].map { |role| roles[role] } array = data.values_at(:id, :description) array << data role = new(*array) role.access = access role.base = self role end |