Class: J2119::RoleNotPresentCondition

Inherits:
Object
  • Object
show all
Defined in:
lib/j2119/conditional.rb

Overview

to be applied to a role/constraint combo, so the constraint is applied

conditionally

These all respond_to constraint_applies(node, roles)

- node is the JSON node being checked
- roles is the roles the node currently has

Instance Method Summary collapse

Constructor Details

#initialize(exclude_roles) ⇒ RoleNotPresentCondition

Returns a new instance of RoleNotPresentCondition.



26
27
28
# File 'lib/j2119/conditional.rb', line 26

def initialize(exclude_roles)
  @excluded_roles = exclude_roles
end

Instance Method Details

#constraint_applies(node, roles) ⇒ Object



34
35
36
# File 'lib/j2119/conditional.rb', line 34

def constraint_applies(node, roles)
  (roles & @excluded_roles).empty?
end

#to_sObject



30
31
32
# File 'lib/j2119/conditional.rb', line 30

def to_s
  "excluded roles: #{@excluded_roles}"
end