Mastodon/app/serializers/rest/collection_item_serializer.rb

20 lines
348 B
Ruby

# frozen_string_literal: true
class REST::CollectionItemSerializer < ActiveModel::Serializer
attributes :id, :state, :created_at
attribute :account_id, if: :accepted_or_pending?
def id
object.id.to_s
end
def account_id
object.account_id.to_s
end
def accepted_or_pending?
object.pending? || object.accepted?
end
end