Class: ValidationErrorReporter::Reporter
- Inherits:
-
Object
- Object
- ValidationErrorReporter::Reporter
- Defined in:
- lib/validation_error_reporter/reporter.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#notifiers ⇒ Object
readonly
Returns the value of attribute notifiers.
-
#profiler ⇒ Object
readonly
Returns the value of attribute profiler.
Instance Method Summary collapse
- #finalize ⇒ Object
-
#initialize(configuration) ⇒ Reporter
constructor
A new instance of Reporter.
- #report(error) ⇒ Object
Constructor Details
#initialize(configuration) ⇒ Reporter
Returns a new instance of Reporter.
5 6 7 8 9 |
# File 'lib/validation_error_reporter/reporter.rb', line 5 def initialize(configuration) @notifiers = configuration.notifiers @profiler = configuration.profiler if configuration.profiler @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
3 4 5 |
# File 'lib/validation_error_reporter/reporter.rb', line 3 def errors @errors end |
#notifiers ⇒ Object (readonly)
Returns the value of attribute notifiers.
3 4 5 |
# File 'lib/validation_error_reporter/reporter.rb', line 3 def notifiers @notifiers end |
#profiler ⇒ Object (readonly)
Returns the value of attribute profiler.
3 4 5 |
# File 'lib/validation_error_reporter/reporter.rb', line 3 def profiler @profiler end |
Instance Method Details
#finalize ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/validation_error_reporter/reporter.rb', line 16 def finalize if profiler profile = profiler.profile(errors) formatter = ProfileFormatter.new notifiers.each { |notifier| notifier.notify(formatter.format(profile)) } end notifiers.each(&:finalize) end |
#report(error) ⇒ Object
11 12 13 14 |
# File 'lib/validation_error_reporter/reporter.rb', line 11 def report(error) @errors << error notifiers.each { |notifier| notifier.notify(error.to_s) } end |