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