Class: Predicated::ConstraintCheckResult

Inherits:
Object
  • Object
show all
Defined in:
lib/predicated/constrain.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConstraintCheckResult

Returns a new instance of ConstraintCheckResult.



52
53
54
# File 'lib/predicated/constrain.rb', line 52

def initialize
  @violations = {}
end

Instance Attribute Details

#violationsObject (readonly)

Returns the value of attribute violations.



51
52
53
# File 'lib/predicated/constrain.rb', line 51

def violations
  @violations
end

Instance Method Details

#pass?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/predicated/constrain.rb', line 56

def pass?
  @violations.empty?
end

#violation(constraint, predicate) ⇒ Object



60
61
62
63
64
# File 'lib/predicated/constrain.rb', line 60

def violation(constraint, predicate)
  @violations[constraint] ||= []
  @violations[constraint] << predicate
  self
end