Module: Access::Role::Base
- Defined in:
- lib/access/role/base.rb
Overview
The module to extend the Database manager
Instance Method Summary collapse
-
#create(role, description = nil, privilege_oids = [], role_oids = []) ⇒ Object
Create a new Role role is a role-oid, 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, privilege_oids = [], role_oids = []) ⇒ Object
Create a new Role role is a role-oid, should be w+ description is a piece of text describing the role privileges are the privileges the role provides
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/access/role/base.rb', line 11 def create(role, description=nil, privilege_oids=[], role_oids=[]) raise "Role #{role} already exists" if exists?(role) role = Role.new(role, description) role.access = access role.base = self add(role) role_oids.each { |role_oid| role.roles.add_oid(role_oid) } privilege_oids.each { |priv| role.privileges.add_oid(priv) } role end |
#load(*args) ⇒ Object
Restore an Access::Privilege from it’s storable data
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/access/role/base.rb', line 27 def load(*args) # :nodoc: return nil unless data = super roles = access.role data[:roles] = data[:roles].map { |role| roles[role] } array = data.values_at(:oid, :description) array << data role = Role.new(*array) role.access = access role.base = self role end |