2020-04-01 12:09:07 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class UserBookmarkListSerializer < ApplicationSerializer
|
2022-04-22 06:23:42 +08:00
|
|
|
attributes :more_bookmarks_url, :bookmarks
|
2020-04-01 12:09:07 +08:00
|
|
|
|
2024-04-17 22:23:47 +08:00
|
|
|
has_many :categories, serializer: CategoryBadgeSerializer, embed: :objects
|
|
|
|
|
2022-04-22 06:23:42 +08:00
|
|
|
def bookmarks
|
2022-05-23 08:07:15 +08:00
|
|
|
object.bookmarks.map do |bm|
|
2022-08-08 22:24:04 +08:00
|
|
|
bm.registered_bookmarkable.serializer.new(
|
|
|
|
bm,
|
|
|
|
**object.bookmark_serializer_opts,
|
|
|
|
scope: scope,
|
|
|
|
root: false,
|
|
|
|
)
|
2022-04-22 06:23:42 +08:00
|
|
|
end
|
|
|
|
end
|
2020-04-01 12:09:07 +08:00
|
|
|
|
|
|
|
def include_more_bookmarks_url?
|
2022-09-01 18:04:00 +08:00
|
|
|
@include_more_bookmarks_url ||= object.has_more
|
2020-04-01 12:09:07 +08:00
|
|
|
end
|
2024-04-17 22:23:47 +08:00
|
|
|
|
|
|
|
def include_categories?
|
|
|
|
scope.can_lazy_load_categories?
|
|
|
|
end
|
2020-04-01 12:09:07 +08:00
|
|
|
end
|