Class: Ingress::PermissionsRepository
- Inherits:
-
Object
- Object
- Ingress::PermissionsRepository
- Defined in:
- lib/ingress/permissions_repository.rb
Defined Under Namespace
Modules: Hashes
Instance Attribute Summary collapse
-
#role_rules ⇒ Object
readonly
Returns the value of attribute role_rules.
Instance Method Summary collapse
- #add_permission(role_identifier, allow, action, subject, conditions = nil) ⇒ Object
- #copy_to_role(role_identifier, permission_repository) ⇒ Object
-
#initialize ⇒ PermissionsRepository
constructor
A new instance of PermissionsRepository.
- #merge(permission_repository) ⇒ Object
- #rules_for(role_identifier, action, subject) ⇒ Object
Constructor Details
#initialize ⇒ PermissionsRepository
Returns a new instance of PermissionsRepository.
7 8 9 10 |
# File 'lib/ingress/permissions_repository.rb', line 7 def initialize @role_rules = Hashes.role_rules @role_subject_action_rule = Hashes.role_subject_action_rule end |
Instance Attribute Details
#role_rules ⇒ Object (readonly)
Returns the value of attribute role_rules.
5 6 7 |
# File 'lib/ingress/permissions_repository.rb', line 5 def role_rules @role_rules end |
Instance Method Details
#add_permission(role_identifier, allow, action, subject, conditions = nil) ⇒ Object
12 13 14 15 |
# File 'lib/ingress/permissions_repository.rb', line 12 def (role_identifier, allow, action, subject, conditions = nil) rule = PermissionRule.new(allows: allow, action: action, subject: subject, conditions: conditions) add_rule(role_identifier, rule) end |
#copy_to_role(role_identifier, permission_repository) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/ingress/permissions_repository.rb', line 38 def copy_to_role(role_identifier, ) .role_rules.each_pair do |_, rules| rules.each do |rule| add_rule(role_identifier, rule) end end self end |
#merge(permission_repository) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/ingress/permissions_repository.rb', line 29 def merge() .role_rules.each_pair do |role_identifier, rules| rules.each do |rule| add_rule(role_identifier, rule) end end self end |
#rules_for(role_identifier, action, subject) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ingress/permissions_repository.rb', line 17 def rules_for(role_identifier, action, subject) rules = [] rules += find_rules(role_identifier, action, subject) rules += find_rules(role_identifier, "*", "*") rules += find_rules(role_identifier, action, "*") rules += find_rules(role_identifier, "*", subject) rules = apply_negative_rules(rules) rules end |