debian-mirror-gitlab/app/serializers/tree_entity.rb
2017-09-10 17:25:29 +05:30

17 lines
425 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|
project_tree_path(request.project, File.join(request.ref, tree.path))
end
end