gitlab-org--gitlab-foss/app/serializers/environment_entity.rb

26 lines
545 B
Ruby
Raw Normal View History

2016-10-28 12:32:07 +00:00
class EnvironmentEntity < Grape::Entity
include RequestAwareEntity
include Gitlab::Routing.url_helpers
expose :id
expose :name
expose :project, with: ProjectEntity
expose :last_deployment,
as: :deployment,
using: API::Entities::Deployment
expose :gitlab_path do |environment|
namespace_project_environment_path(
environment.project.namespace,
environment.project,
environment
)
end
expose :can_read?
2016-10-28 12:32:07 +00:00
def can_read?
Ability.allowed?(request.user, :read_environment, @object)
2016-10-28 12:32:07 +00:00
end
end