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

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

Instance Method Summary collapse

Constructor Details

#initialize(gate, value = nil) ⇒ Gate

Returns a new instance of Gate.



6
7
8
9
# File 'lib/flipper/api/v1/decorators/gate.rb', line 6

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

Instance Method Details

#as_json(exclude_name: false) ⇒ Object



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

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