Class: Flipper::Gates::Boolean

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

Instance Method Summary collapse

Methods inherited from Flipper::Gate

#initialize, #inspect

Constructor Details

This class inherits a constructor from Flipper::Gate

Instance Method Details

#data_typeObject



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

def data_type
  :boolean
end

#enabled?(value) ⇒ Boolean

Returns:



18
19
20
# File 'lib/flipper/gates/boolean.rb', line 18

def enabled?(value)
  !!value
end

#keyObject

Internal: Name converted to value safe for adapter.



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?(context) ⇒ Boolean

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

Returns true if explicitly set to true, false if explicitly set to false or nil if not explicitly set.

Returns:



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

def open?(context)
  context.values[key]
end

#protects?(thing) ⇒ Boolean

Returns:



34
35
36
37
38
39
40
41
# File 'lib/flipper/gates/boolean.rb', line 34

def protects?(thing)
  case thing
  when Types::Boolean, TrueClass, FalseClass
    true
  else
    false
  end
end

#wrap(thing) ⇒ Object



30
31
32
# File 'lib/flipper/gates/boolean.rb', line 30

def wrap(thing)
  Types::Boolean.wrap(thing)
end