Class: Cbac::PrivilegeSet
- Inherits:
-
Object
- Object
- Cbac::PrivilegeSet
- Defined in:
- lib/cbac/privilege_set.rb
Overview
Defines sets of privileges
To create a new set: PrivilegeSet.add :set_name, “Some comment on what this set does”
To retrieve a privilegeset, use the sets attribute. This is a Hash containing PrivilegeSetRecords. Usage: PrivilegeSet.sets(:set_name). If the PrivilegeSet already exists, an ArgumentError is thrown stating the set was already defined.
Class Attribute Summary collapse
-
.sets ⇒ Object
readonly
Hash containing all the PrivilegeSetRecords.
Class Method Summary collapse
-
.add(symbol, comment) ⇒ Object
Create a new PrivilegeSet.
Class Attribute Details
.sets ⇒ Object (readonly)
Hash containing all the PrivilegeSetRecords
13 14 15 |
# File 'lib/cbac/privilege_set.rb', line 13 def sets @sets end |
Class Method Details
.add(symbol, comment) ⇒ Object
Create a new PrivilegeSet
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/cbac/privilege_set.rb', line 16 def add(symbol, comment) # initialize variables (if applicable) @sets = Hash.new if @sets.nil? # check for double creation raise ArgumentError, "CBAC: PrivilegeSet was already defined: #{symbol.to_s}" if @sets.include?(symbol) # Create record if privilege set doesn't exist record = Cbac::PrivilegeSetRecord.find_or_create_by(name: symbol.to_s) record.set_comment(comment) record.save @sets[symbol] = record end |