relationship_serializer.rb 750 B

123456789101112131415161718192021222324252627282930
  1. # frozen_string_literal: true
  2. class REST::RelationshipSerializer < ActiveModel::Serializer
  3. attributes :id, :following, :followed_by, :blocking,
  4. :muting, :requested, :domain_blocking
  5. def following
  6. instance_options[:relationships].following[object.id] || false
  7. end
  8. def followed_by
  9. instance_options[:relationships].followed_by[object.id] || false
  10. end
  11. def blocking
  12. instance_options[:relationships].blocking[object.id] || false
  13. end
  14. def muting
  15. instance_options[:relationships].muting[object.id] || false
  16. end
  17. def requested
  18. instance_options[:relationships].requested[object.id] || false
  19. end
  20. def domain_blocking
  21. instance_options[:relationships].domain_blocking[object.id] || false
  22. end
  23. end