Class: Flipper::Gates::Boolean

Inherits:
Flipper::Gate show all
Defined in:
lib/flipper/gates/boolean.rb

Constant Summary

Constants inherited from Flipper::Gate

Flipper::Gate::InstrumentationName

Instance Attribute Summary

Attributes inherited from Flipper::Gate

#feature, #instrumenter

Instance Method Summary collapse

Methods inherited from Flipper::Gate

#adapter_key, #disable, #enable, #enabled?, #initialize, #inspect, #instrument, #toggle

Constructor Details

This class inherits a constructor from Flipper::Gate

Instance Method Details

#descriptionObject



30
31
32
33
34
35
36
# File 'lib/flipper/gates/boolean.rb', line 30

def description
  if enabled?
    'Enabled'
  else
    'Disabled'
  end
end

#keyObject

Internal: The piece of the adapter key that is unique to the gate class.



10
11
12
# File 'lib/flipper/gates/boolean.rb', line 10

def key
  :boolean
end

#nameObject

Internal: The name of the gate. Used for instrumentation, etc.



5
6
7
# File 'lib/flipper/gates/boolean.rb', line 5

def name
  :boolean
end

#open?(thing) ⇒ Boolean

Internal: Checks if the gate is open for a thing.

Returns true if gate open for thing, false if not.

Returns:



22
23
24
# File 'lib/flipper/gates/boolean.rb', line 22

def open?(thing)
  instrument(:open?, thing) { |payload| toggle.value }
end

#protects?(thing) ⇒ Boolean

Returns:



26
27
28
# File 'lib/flipper/gates/boolean.rb', line 26

def protects?(thing)
  thing.is_a?(Flipper::Types::Boolean)
end

#toggle_classObject

Internal: The toggle class used to enable/disable the gate for a thing.



15
16
17
# File 'lib/flipper/gates/boolean.rb', line 15

def toggle_class
  Toggles::Boolean
end