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