Commit d7a8bada authored by Stan Hu's avatar Stan Hu

Merge branch 'refactoring-entities-file-25' into 'master'

Separate token into own class files

See merge request gitlab-org/gitlab!24974
parents b55a5eab 6b76d9be
---
title: Separate token entities into own class files
merge_request: 24974
author: Rajendra Kadam
type: added
...@@ -169,36 +169,6 @@ module API ...@@ -169,36 +169,6 @@ module API
expose :last_pipeline, using: Entities::PipelineBasic expose :last_pipeline, using: Entities::PipelineBasic
expose :variables, using: Entities::Variable expose :variables, using: Entities::Variable
end end
class ImpersonationToken < PersonalAccessToken
expose :impersonation
end
class ImpersonationTokenWithToken < PersonalAccessTokenWithToken
expose :impersonation
end
class FeatureGate < Grape::Entity
expose :key
expose :value
end
class Feature < Grape::Entity
expose :name
expose :state
expose :gates, using: FeatureGate do |model|
model.gates.map do |gate|
value = model.gate_values[gate.key]
# By default all gate values are populated. Only show relevant ones.
if (value.is_a?(Integer) && value.zero?) || (value.is_a?(Set) && value.empty?)
next
end
{ key: gate.key, value: value }
end.compact
end
end
end end
end end
......
# frozen_string_literal: true
module API
module Entities
class Feature < Grape::Entity
expose :name
expose :state
expose :gates, using: Entities::FeatureGate do |model|
model.gates.map do |gate|
value = model.gate_values[gate.key]
# By default all gate values are populated. Only show relevant ones.
if (value.is_a?(Integer) && value.zero?) || (value.is_a?(Set) && value.empty?)
next
end
{ key: gate.key, value: value }
end.compact
end
end
end
end
# frozen_string_literal: true
module API
module Entities
class FeatureGate < Grape::Entity
expose :key
expose :value
end
end
end
# frozen_string_literal: true
module API
module Entities
class ImpersonationToken < Entities::PersonalAccessToken
expose :impersonation
end
end
end
# frozen_string_literal: true
module API
module Entities
class ImpersonationTokenWithToken < Entities::PersonalAccessTokenWithToken
expose :impersonation
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment