Class: Request::Statistics::Summary

Inherits:
Object
  • Object
show all
Defined in:
app/models/request/statistics.rb

Overview

rubocop:todo Style/Documentation

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSummary

Returns a new instance of Summary.


53
54
55
# File 'app/models/request/statistics.rb', line 53

def initialize
  @counters = Hash.new { |h, k| h[k] = Counter.new }
end

Class Method Details

.summary_counter(name) ⇒ Object


59
60
61
62
63
64
65
66
67
68
69
70
# File 'app/models/request/statistics.rb', line 59

def self.summary_counter(name)
  line = __LINE__ + 1
  class_eval(
    "
    def #{name}
      @counters.values.map(&#{name.to_sym.inspect}).sum
    end
  ",
    __FILE__,
    line
  )
end