This commit is contained in:
2026-02-22 01:00:40 +09:00
parent a01c63d972
commit 704efef046
7 changed files with 66 additions and 32 deletions
@@ -0,0 +1,16 @@
# frozen_string_literal: true
module WikiPageRepr
BASE = { methods: [:title] }.freeze
module_function
def base wiki_page
wiki_page.as_json(BASE)
end
def many wiki_pages
wiki_pages.map { |p| base(p) }
end
end
+16
View File
@@ -0,0 +1,16 @@
# frozen_string_literal: true
module PostRepr
BASE = { include: { tags: TagRepr::BASE } }.freeze
module_function
def base post
post.as_json(BASE)
end
def many posts
posts.map { |p| base(p) }
end
end
+16
View File
@@ -0,0 +1,16 @@
# frozen_string_literal: true
module TagRepr
BASE = { only: [:id, :category, :post_count], methods: [:name, :has_wiki] }.freeze
module_function
def base tag
tag.as_json(BASE)
end
def many tags
tags.map { |t| base(t) }
end
end