This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
|
||||
module MaterialRepr
|
||||
BASE = { only: [:id, :url, :parent_id, :created_at, :updated_at],
|
||||
include: { created_by_user: UserRepr::BASE, tag: TagRepr::BASE } }.freeze
|
||||
|
||||
module_function
|
||||
|
||||
def base(material)
|
||||
material.as_json(BASE)
|
||||
end
|
||||
|
||||
def many(materials)
|
||||
materials.map { |m| base(m) }
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user