You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
468 B

  1. # frozen_string_literal: true
  2. class REST::Admin::MeasureSerializer < ActiveModel::Serializer
  3. attributes :key, :unit, :total
  4. attribute :human_value, if: -> { object.respond_to?(:value_to_human_value) }
  5. attribute :previous_total, if: -> { object.total_in_time_range? }
  6. attribute :data
  7. def total
  8. object.total.to_s
  9. end
  10. def human_value
  11. object.value_to_human_value(object.total)
  12. end
  13. def previous_total
  14. object.previous_total.to_s
  15. end
  16. end