This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2021-10-14 11:44:59 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class REST::Admin::MeasureSerializer < ActiveModel::Serializer
|
2022-03-08 23:52:32 -08:00
|
|
|
attributes :key, :unit, :total
|
|
|
|
|
|
|
|
attribute :human_value, if: -> { object.respond_to?(:value_to_human_value) }
|
|
|
|
attribute :previous_total, if: -> { object.total_in_time_range? }
|
|
|
|
attribute :data
|
2021-10-14 11:44:59 -07:00
|
|
|
|
|
|
|
def total
|
|
|
|
object.total.to_s
|
|
|
|
end
|
|
|
|
|
2022-03-08 23:52:32 -08:00
|
|
|
def human_value
|
|
|
|
object.value_to_human_value(object.total)
|
|
|
|
end
|
|
|
|
|
2021-10-14 11:44:59 -07:00
|
|
|
def previous_total
|
|
|
|
object.previous_total.to_s
|
|
|
|
end
|
|
|
|
end
|