Class: SnipSnip::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/snip_snip/reporter.rb

Overview

Handles outputting unnecessarily selected columns to the logs.

Defined Under Namespace

Classes: Result

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeReporter

Returns a new instance of Reporter.



17
18
19
# File 'lib/snip_snip/reporter.rb', line 17

def initialize
  @results = find_results
end

Instance Attribute Details

#resultsObject (readonly)

Returns the value of attribute results.



15
16
17
# File 'lib/snip_snip/reporter.rb', line 15

def results
  @results
end

Class Method Details

.report(controller) ⇒ Object

Report on the specified controller.



37
38
39
# File 'lib/snip_snip/reporter.rb', line 37

def self.report(controller)
  new.report(controller)
end

Instance Method Details

#report(controller) ⇒ Object

Report on the unused columns that were selected during the course of the processing the action on the given controller.



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/snip_snip/reporter.rb', line 23

def report(controller)
  return if results.empty?

  action_display = "#{controller.controller_name}##{controller.action_name}"
  SnipSnip.logger.info(action_display)

  results.sort_by(&:report).each do |result|
    SnipSnip.logger.info("  #{result.report}")
  end
ensure
  Registry.clear
end