featured_tag_serializer.rb 463 B

123456789101112131415161718192021222324252627
  1. # frozen_string_literal: true
  2. class REST::FeaturedTagSerializer < ActiveModel::Serializer
  3. include RoutingHelper
  4. attributes :id, :name, :url, :statuses_count, :last_status_at
  5. def id
  6. object.id.to_s
  7. end
  8. def url
  9. short_account_tag_url(object.account, object.tag)
  10. end
  11. def name
  12. object.display_name
  13. end
  14. def statuses_count
  15. object.statuses_count.to_s
  16. end
  17. def last_status_at
  18. object.last_status_at&.to_date&.iso8601
  19. end
  20. end