Class: Rushiro::Permissions
- Inherits:
-
Object
- Object
- Rushiro::Permissions
- Defined in:
- lib/rushiro/permissions.rb
Instance Attribute Summary collapse
-
#permissions ⇒ Object
readonly
Returns the value of attribute permissions.
Instance Method Summary collapse
- #add_permission(perm) ⇒ Object
-
#initialize(entries) ⇒ Permissions
constructor
A new instance of Permissions.
- #permitted?(perm) ⇒ Boolean
- #remove_permission(perm) ⇒ Object
- #serialize ⇒ Object
Constructor Details
#initialize(entries) ⇒ Permissions
Returns a new instance of Permissions.
4 5 6 7 8 |
# File 'lib/rushiro/permissions.rb', line 4 def initialize(entries) @permissions = entries.map do || Permission.new() end || [] end |
Instance Attribute Details
#permissions ⇒ Object (readonly)
Returns the value of attribute permissions.
3 4 5 |
# File 'lib/rushiro/permissions.rb', line 3 def @permissions end |
Instance Method Details
#add_permission(perm) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/rushiro/permissions.rb', line 15 def (perm) to_add = Permission.new(perm) return false if @permissions.any?{|_p| _p == to_add} @permissions << to_add true end |
#permitted?(perm) ⇒ Boolean
10 11 12 13 |
# File 'lib/rushiro/permissions.rb', line 10 def permitted?(perm) return nil if @permissions.empty? @permissions.any? { || .implied?(perm) } end |
#remove_permission(perm) ⇒ Object
22 23 24 |
# File 'lib/rushiro/permissions.rb', line 22 def (perm) !!@permissions.delete(Permission.new(perm)) end |
#serialize ⇒ Object
26 27 28 |
# File 'lib/rushiro/permissions.rb', line 26 def serialize @permissions.map(&:serialize) end |