lib/flipper/api/v1/decorators/feature.rb in flipper-api-0.24.0 vs lib/flipper/api/v1/decorators/feature.rb in flipper-api-0.24.1

- old
+ new

@@ -8,20 +8,23 @@ class Feature < SimpleDelegator # Public: The feature being decorated. alias_method :feature, :__getobj__ # Public: Returns instance as hash that is ready to be json dumped. - def as_json - gate_values = feature.adapter.get(self) - gates_json = gates.map do |gate| - Decorators::Gate.new(gate, gate_values[gate.key]).as_json - end - - { + def as_json(exclude_gates: false) + result = { 'key' => key, 'state' => state.to_s, - 'gates' => gates_json, } + + unless exclude_gates + gate_values = feature.adapter.get(self) + result['gates'] = gates.map do |gate| + Decorators::Gate.new(gate, gate_values[gate.key]).as_json + end + end + + result end end end end end