Class: ModelValidator::StatsHandler
- Inherits:
-
Object
- Object
- ModelValidator::StatsHandler
- Defined in:
- lib/model_validator/stats_handler.rb
Overview
This handler computes validation statistics
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
- #after_validation(_) ⇒ Object
-
#initialize ⇒ StatsHandler
constructor
A new instance of StatsHandler.
- #on_violation(_) ⇒ Object
Constructor Details
#initialize ⇒ StatsHandler
Returns a new instance of StatsHandler.
13 14 15 |
# File 'lib/model_validator/stats_handler.rb', line 13 def initialize @result = Result.new(0, 0) end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
11 12 13 |
# File 'lib/model_validator/stats_handler.rb', line 11 def result @result end |
Instance Method Details
#after_validation(_) ⇒ Object
21 22 23 |
# File 'lib/model_validator/stats_handler.rb', line 21 def after_validation(_) @result.total += 1 end |
#on_violation(_) ⇒ Object
17 18 19 |
# File 'lib/model_validator/stats_handler.rb', line 17 def on_violation(_) @result.violations += 1 end |