Class: Rushiro::AccessLevels
- Inherits:
-
Object
- Object
- Rushiro::AccessLevels
- Defined in:
- lib/rushiro/access_levels.rb
Instance Attribute Summary collapse
-
#individual ⇒ Object
readonly
Returns the value of attribute individual.
-
#musicglue ⇒ Object
readonly
Returns the value of attribute musicglue.
-
#organization ⇒ Object
readonly
Returns the value of attribute organization.
Instance Method Summary collapse
- #add_permission(perm) ⇒ Object
-
#initialize(hash) ⇒ AccessLevels
constructor
A new instance of AccessLevels.
- #permitted?(perm) ⇒ Boolean
- #remove_permission(perm) ⇒ Object
- #serialize ⇒ Object
Constructor Details
#initialize(hash) ⇒ AccessLevels
Returns a new instance of AccessLevels.
4 5 6 7 8 |
# File 'lib/rushiro/access_levels.rb', line 4 def initialize(hash) @individual = Permissions.new(hash[:individual] || []) @organization = Permissions.new(hash[:organization] || []) @system = Permissions.new(hash[:system] || []) end |
Instance Attribute Details
#individual ⇒ Object (readonly)
Returns the value of attribute individual.
3 4 5 |
# File 'lib/rushiro/access_levels.rb', line 3 def individual @individual end |
#musicglue ⇒ Object (readonly)
Returns the value of attribute musicglue.
3 4 5 |
# File 'lib/rushiro/access_levels.rb', line 3 def musicglue @musicglue end |
#organization ⇒ Object (readonly)
Returns the value of attribute organization.
3 4 5 |
# File 'lib/rushiro/access_levels.rb', line 3 def organization @organization end |
Instance Method Details
#add_permission(perm) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rushiro/access_levels.rb', line 14 def (perm) level, rest = perm.split(GSEP, 2) case level when 'individual' @individual.(rest) when 'organization' @organization.(rest) when 'system' @system.(rest) else raise ArgumentError.new("Could not add permission for level: #{level} of #{level}#{SEP}#{perm}") end end |
#permitted?(perm) ⇒ Boolean
10 11 12 |
# File 'lib/rushiro/access_levels.rb', line 10 def permitted?(perm) @system.permitted?(perm) || @organization.permitted?(perm) || @individual.permitted?(perm) end |
#remove_permission(perm) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rushiro/access_levels.rb', line 28 def (perm) level, rest = perm.split(GSEP, 2) case level when 'individual' @individual.(rest) when 'organization' @organization.(rest) when 'system' @system.(rest) else raise ArgumentError.new("Could not remove permission for level: #{level} of #{level}#{SEP}#{rest}") end end |
#serialize ⇒ Object
41 42 43 |
# File 'lib/rushiro/access_levels.rb', line 41 def serialize Hash[:individual, @individual.serialize, :organization, @organization.serialize, :system, @system.serialize] end |