gitlab-org--gitlab-foss/app/serializers/tree_entity.rb
Dmitriy Zaporozhets f516b8d0d7
Expose last_commit information for tree and blob when serialized
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2017-06-22 10:50:55 +02:00

17 lines
462 B
Ruby

class TreeEntity < Grape::Entity
include RequestAwareEntity
expose :id, :path, :name, :mode
expose :last_commit do |tree|
request.project.repository.last_commit_for_path(tree.commit_id, tree.path)
end
expose :icon do |tree|
IconsHelper.file_type_icon_class('folder', tree.mode, tree.name)
end
expose :url do |tree|
namespace_project_tree_path(request.project.namespace, request.project, File.join(request.ref, tree.path))
end
end