Class: Ingress::PermissionRule
- Inherits:
-
Object
- Object
- Ingress::PermissionRule
- Defined in:
- lib/ingress/permission_rule.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Instance Method Summary collapse
- #allows? ⇒ Boolean
-
#initialize(allows:, action:, subject:, conditions: nil) ⇒ PermissionRule
constructor
A new instance of PermissionRule.
- #match?(given_action, given_subject, user) ⇒ Boolean
Constructor Details
#initialize(allows:, action:, subject:, conditions: nil) ⇒ PermissionRule
Returns a new instance of PermissionRule.
5 6 7 8 9 10 |
# File 'lib/ingress/permission_rule.rb', line 5 def initialize(allows:, action:, subject:, conditions: nil) @allows = allows @action = action @subject = subject @conditions = [conditions].compact.flatten end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
3 4 5 |
# File 'lib/ingress/permission_rule.rb', line 3 def action @action end |
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
3 4 5 |
# File 'lib/ingress/permission_rule.rb', line 3 def conditions @conditions end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
3 4 5 |
# File 'lib/ingress/permission_rule.rb', line 3 def subject @subject end |
Instance Method Details
#allows? ⇒ Boolean
12 13 14 |
# File 'lib/ingress/permission_rule.rb', line 12 def allows? @allows end |
#match?(given_action, given_subject, user) ⇒ Boolean
16 17 18 19 20 21 |
# File 'lib/ingress/permission_rule.rb', line 16 def match?(given_action, given_subject, user) return false unless action_matches?(given_action) return false unless subject_matches?(given_subject) conditions_match?(user, given_subject) end |