2021-10-14 14:44:59 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class REST::Admin::MeasureSerializer < ActiveModel::Serializer
|
2022-03-09 02:52:32 -05: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 14:44:59 -04:00
|
|
|
|
|
|
|
def total
|
|
|
|
object.total.to_s
|
|
|
|
end
|
|
|
|
|
2022-03-09 02:52:32 -05:00
|
|
|
def human_value
|
|
|
|
object.value_to_human_value(object.total)
|
|
|
|
end
|
|
|
|
|
2021-10-14 14:44:59 -04:00
|
|
|
def previous_total
|
|
|
|
object.previous_total.to_s
|
|
|
|
end
|
|
|
|
end
|