Class: Flipper::Api::V1::Decorators::Gate

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/flipper/api/v1/decorators/gate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gate, value = nil) ⇒ Gate

Returns a new instance of Gate.



12
13
14
15
# File 'lib/flipper/api/v1/decorators/gate.rb', line 12

def initialize(gate, value = nil)
  super gate
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Public: the value for the gate from the adapter.



10
11
12
# File 'lib/flipper/api/v1/decorators/gate.rb', line 10

def value
  @value
end

Instance Method Details

#as_json(exclude_name: false) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/flipper/api/v1/decorators/gate.rb', line 17

def as_json(exclude_name: false)
  as_json = {
    'key' => gate.key.to_s,
    'value' => value_as_json,
  }
  as_json['name'] = gate.name.to_s unless exclude_name
  as_json
end