debian-mirror-gitlab/lib/api/entities/feature.rb

33 lines
953 B
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
module API
module Entities
class Feature < Grape::Entity
2023-01-13 00:05:48 +05:30
expose :name, documentation: { type: 'string', example: 'experimental_feature' }
expose :state, documentation: { type: 'string', example: 'off' }
2020-03-13 15:44:24 +05:30
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.
2020-10-24 23:57:45 +05:30
if (value.is_a?(Integer) && value == 0) || (value.is_a?(Set) && value.empty?)
2020-03-13 15:44:24 +05:30
next
end
{ key: gate.key, value: value }
end.compact
end
2021-02-22 17:27:13 +05:30
class Definition < Grape::Entity
::Feature::Definition::PARAMS.each do |param|
expose param
end
end
expose :definition, using: Definition do |feature|
::Feature::Definition.definitions[feature.name.to_sym]
end
2020-03-13 15:44:24 +05:30
end
end
end