Sha256: ecd53b01d77a7f4e90f0d895ce0b304b38f4710e7b786f0d2de0468c6dd79150
Contents?: true
Size: 678 Bytes
Versions: 7
Compression:
Stored size: 678 Bytes
Contents
class MeasurementsPresenter attr_reader :measurements def initialize(measurements) @measurements = measurements end def to_json(*args) Houston.benchmark "[#{self.class.name.underscore}] Render JSON" do MultiJson.dump(as_json(*args)) end end def as_json(*args) Houston.benchmark "[#{self.class.name.underscore}] Prepare JSON" do measurements.pluck(:name, :taken_at, :value, :subject_type, :subject_id) .map do |name, timestamp, value, subject_type, subject_id| { timestamp: timestamp, name: name, value: value, subject: { type: subject_type, id: subject_id } } end end end end
Version data entries
7 entries across 7 versions & 1 rubygems