Class: MetricsApi::V3::Presenters::Record

Inherits:
Object
  • Object
show all
Defined in:
app/services/metrics_api/v3/presenters/record.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(faceted_metrics) ⇒ Record

Returns a new instance of Record.


6
7
8
# File 'app/services/metrics_api/v3/presenters/record.rb', line 6

def initialize(faceted_metrics)
  @m = faceted_metrics
end

Class Method Details

.to_procObject


20
21
22
# File 'app/services/metrics_api/v3/presenters/record.rb', line 20

def self.to_proc
  ->(metric) { new(metric).to_json }
end

Instance Method Details

#to_jsonObject


10
11
12
13
14
15
16
17
18
# File 'app/services/metrics_api/v3/presenters/record.rb', line 10

def to_json
  {
    id: @m.name,
    total_active_records: @m.total_active_records,
    total_new_records: @m.total_new_records,
    category_counts: @m.category_counts || {},
    copyright_counts: @m.copyright_counts || {}
  }
end