gab-social/app/serializers/rest/group_relationship_serializer.rb

22 lines
455 B
Ruby
Raw Normal View History

2019-07-02 03:10:25 -04:00
# frozen_string_literal: true
class REST::GroupRelationshipSerializer < ActiveModel::Serializer
2019-07-20 02:04:08 +03:00
attributes :id, :member, :admin, :unread_count
2019-07-02 03:10:25 -04:00
def id
object.id.to_s
end
def member
instance_options[:relationships].member[object.id] ? true : false
end
def admin
instance_options[:relationships].admin[object.id] ? true : false
end
2019-07-20 02:04:08 +03:00
def unread_count
instance_options[:relationships].unread_count[object.id] || 0
end
2019-07-02 03:10:25 -04:00
end