Class: ForemanTasks::Task::Summarizer::Record
- Inherits:
-
Object
- Object
- ForemanTasks::Task::Summarizer::Record
- Defined in:
- app/models/foreman_tasks/task/summarizer.rb
Overview
number of recent/total tasks for specific classification (state/result)
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize ⇒ Record
constructor
A new instance of Record.
- #to_h ⇒ Object
-
#update(field, counts) ⇒ Object
updates ‘field` (one of [:recent, :total]) with counts from aggregated_scope.
Constructor Details
#initialize ⇒ Record
Returns a new instance of Record.
8 9 10 |
# File 'app/models/foreman_tasks/task/summarizer.rb', line 8 def initialize @data = { recent: 0, total: 0 } end |
Instance Method Details
#to_h ⇒ Object
12 13 14 |
# File 'app/models/foreman_tasks/task/summarizer.rb', line 12 def to_h @data.dup end |
#update(field, counts) ⇒ Object
updates ‘field` (one of [:recent, :total]) with counts from aggregated_scope
17 18 19 20 |
# File 'app/models/foreman_tasks/task/summarizer.rb', line 17 def update(field, counts) raise ArgumentError, "Unexpected field #{field}" unless @data.key?(field) @data[field] = counts.sum(&:count) end |