Class: Flipper::Exporters::Json::V1

Inherits:
Object
  • Object
show all
Defined in:
lib/flipper/exporters/json/v1.rb

Constant Summary collapse

VERSION =
1

Instance Method Summary collapse

Instance Method Details

#call(adapter) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/flipper/exporters/json/v1.rb', line 10

def call(adapter)
  features = adapter.get_all

  # Convert sets to arrays for json
  features.each do |feature_key, gates|
    gates.each do |key, value|
      case value
      when Set
        features[feature_key][key] = value.to_a
      end
    end
  end

  json = JSON.dump({
    version: VERSION,
    features: features,
  })

  Json::Export.new(contents: json, version: VERSION)
end