ファイル
btrc-hub/backend/app/representations/wiki_page_repr.rb
T
2026-10-05 01:22:54 +09:00

32 行
790 B
Ruby

# frozen_string_literal: true
module WikiPageRepr
BASE = { methods: [:title, :deprecated_at] }.freeze
module_function
def base wiki_page
wiki_page.as_json(BASE)
end
def tag_description description
tag = description.tag
{ 'id' => description.id,
'tag_name_id' => tag.tag_name('ja')&.id,
'body' => description.body,
'created_user_id' => description.created_by_user_id,
'updated_user_id' => description.updated_by_user_id,
'created_at' => description.created_at,
'updated_at' => description.updated_at,
'discarded_at' => nil,
'version_no' => description.version_no,
'title' => tag.name('ja'),
'deprecated_at' => tag.deprecated_at }
end
def many wiki_pages
wiki_pages.map { |p| base(p) }
end
end