about summary refs log tree commit diff
path: root/app/serializers/rest/admin/cohort_serializer.rb
blob: f6817361655e0fc836a1249e9a9037d214a18b74 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

class REST::Admin::CohortSerializer < ActiveModel::Serializer
  attributes :period, :frequency

  class CohortDataSerializer < ActiveModel::Serializer
    attributes :date, :rate, :value

    def date
      object.date.iso8601
    end
  end

  has_many :data, serializer: CohortDataSerializer

  def period
    object.period.iso8601
  end
end