Class: ColumnsTrace::LogReporter
- Inherits:
-
Object
- Object
- ColumnsTrace::LogReporter
- Defined in:
- lib/columns_trace/log_reporter.rb
Overview
Reporter that reports into the provided logger.
Instance Method Summary collapse
-
#initialize(logger) ⇒ LogReporter
constructor
A new instance of LogReporter.
-
#report(title, created_records) ⇒ Object
Main reporter’s method.
Constructor Details
#initialize(logger) ⇒ LogReporter
Returns a new instance of LogReporter.
6 7 8 |
# File 'lib/columns_trace/log_reporter.rb', line 6 def initialize(logger) @logger = logger end |
Instance Method Details
#report(title, created_records) ⇒ Object
Main reporter’s method
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/columns_trace/log_reporter.rb', line 16 def report(title, created_records) lines = [] created_records.group_by(&:model).each do |model, grouped_created_records| lines.concat(lines_for_created_records(model, grouped_created_records)) end if lines.any? @logger.info("#{title}\n#{lines.join("\n")}") end end |