Class: Predicated::ConstraintCheckResult
- Defined in:
- lib/predicated/constrain.rb
Instance Attribute Summary collapse
-
#violations ⇒ Object
readonly
Returns the value of attribute violations.
Instance Method Summary collapse
-
#initialize ⇒ ConstraintCheckResult
constructor
A new instance of ConstraintCheckResult.
- #pass? ⇒ Boolean
- #violation(constraint, predicate) ⇒ Object
Constructor Details
#initialize ⇒ ConstraintCheckResult
Returns a new instance of ConstraintCheckResult.
52 53 54 |
# File 'lib/predicated/constrain.rb', line 52 def initialize @violations = {} end |
Instance Attribute Details
#violations ⇒ Object (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
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 |