Class: ModelValidator::StatsHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/model_validator/stats_handler.rb

Overview

This handler computes validation statistics

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStatsHandler

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

#resultObject (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