Class: Flipper::Api::V1::Decorators::Feature
- Inherits:
-
Object
- Object
- Flipper::Api::V1::Decorators::Feature
- Defined in:
- lib/flipper/api/v1/decorators/feature.rb
Instance Method Summary collapse
-
#as_json(exclude_gates: false, exclude_gate_names: false) ⇒ Object
Public: Returns instance as hash that is ready to be json dumped.
-
#initialize(feature) ⇒ Feature
constructor
A new instance of Feature.
Constructor Details
#initialize(feature) ⇒ Feature
Returns a new instance of Feature.
8 9 10 |
# File 'lib/flipper/api/v1/decorators/feature.rb', line 8 def initialize(feature) @feature = feature end |
Instance Method Details
#as_json(exclude_gates: false, exclude_gate_names: false) ⇒ Object
Public: Returns instance as hash that is ready to be json dumped.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/flipper/api/v1/decorators/feature.rb', line 13 def as_json(exclude_gates: false, exclude_gate_names: false) result = { 'key' => @feature.key, 'state' => @feature.state.to_s, } unless exclude_gates gate_values = @feature.adapter.get(@feature) result['gates'] = @feature.gates.map do |gate| Decorators::Gate.new(gate, gate_values[gate.key]).as_json(exclude_name: exclude_gate_names) end end result end |