class J2119::Constraint

These all respond_to check(node, path, problem)

- node is the JSON node being checked
- path is the current path, for reporting practices
- problems is a list of problem reports

TODO: Add a “role” argument to enrich error reporting

Public Class Methods

new() click to toggle source
# File lib/j2119/constraints.rb, line 25
def initialize
  @conditions = []
end

Public Instance Methods

add_condition(condition) click to toggle source
# File lib/j2119/constraints.rb, line 29
def add_condition(condition)
  @conditions << condition
end
applies(node, role) click to toggle source
# File lib/j2119/constraints.rb, line 33
def applies(node, role)
  return @conditions.empty? ||
    @conditions.map{|c| c.constraint_applies(node, role)}.any?
end