about summary refs log tree commit diff
path: root/app/serializers/rest/v1/filter_serializer.rb
blob: 455f17efdb3343865b8ec80fff8843c42f8e1e78 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true

class REST::V1::FilterSerializer < ActiveModel::Serializer
  attributes :id, :phrase, :context, :whole_word, :expires_at,
             :irreversible

  delegate :context, :expires_at, to: :custom_filter

  def id
    object.id.to_s
  end

  def phrase
    object.keyword
  end

  def irreversible
    custom_filter.irreversible?
  end

  private

  def custom_filter
    object.custom_filter
  end
end