Class: Request::Statistics::Summary

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSummary

Returns a new instance of Summary


56
57
58
# File 'app/models/request/statistics.rb', line 56

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

Class Method Details

.summary_counter(name) ⇒ Object


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

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