# 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