cohort_serializer.rb 374 B

12345678910111213141516171819
  1. # frozen_string_literal: true
  2. class REST::Admin::CohortSerializer < ActiveModel::Serializer
  3. attributes :period, :frequency
  4. class CohortDataSerializer < ActiveModel::Serializer
  5. attributes :date, :rate, :value
  6. def date
  7. object.date.iso8601
  8. end
  9. end
  10. has_many :data, serializer: CohortDataSerializer
  11. def period
  12. object.period.iso8601
  13. end
  14. end