Welcome to mirror list, hosted at ThFree Co, Russian Federation.

feature.rb « entities « api « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 48dd5a22a7e429bcb30f7a6de5d56ca4a23edfa7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# frozen_string_literal: true

module API
  module Entities
    class Feature < Grape::Entity
      expose :name, documentation: { type: 'string', example: 'experimental_feature' }
      expose :state, documentation: { type: 'string', example: 'off' }
      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 == 0) || (value.is_a?(Set) && value.empty?)
            next
          end

          { key: gate.key, value: value }
        end.compact
      end

      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
    end
  end
end