Class: Flipper::Gate

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

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Gate

Public



4
5
# File 'lib/flipper/gate.rb', line 4

def initialize(options = {})
end

Instance Method Details

#data_typeObject



17
18
19
# File 'lib/flipper/gate.rb', line 17

def data_type
  raise 'Not implemented'
end

#enabled?(value) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/flipper/gate.rb', line 21

def enabled?(value)
  raise 'Not implemented'
end

#inspectObject

Public: Pretty string version for debugging.



46
47
48
49
50
51
52
53
# File 'lib/flipper/gate.rb', line 46

def inspect
  attributes = [
    "name=#{name.inspect}",
    "key=#{key.inspect}",
    "data_type=#{data_type.inspect}",
  ]
  "#<#{self.class.name}:#{object_id} #{attributes.join(', ')}>"
end

#keyObject

Private: Name converted to value safe for adapter. Implemented in subclass.



13
14
15
# File 'lib/flipper/gate.rb', line 13

def key
  raise 'Not implemented'
end

#nameObject

Public: The name of the gate. Implemented in subclass.



8
9
10
# File 'lib/flipper/gate.rb', line 8

def name
  raise 'Not implemented'
end

#open?(thing, value, options = {}) ⇒ Boolean

Internal: Check if a gate is open for a thing. Implemented in subclass.

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

Returns:

  • (Boolean)


28
29
30
# File 'lib/flipper/gate.rb', line 28

def open?(thing, value, options = {})
  false
end

#protects?(thing) ⇒ Boolean

Internal: Check if a gate is protects a thing. Implemented in subclass.

Returns true if gate protects thing, false if not.

Returns:

  • (Boolean)


35
36
37
# File 'lib/flipper/gate.rb', line 35

def protects?(thing)
  false
end

#wrap(thing) ⇒ Object

Internal: Allows gate to wrap thing using one of the supported flipper types so adapters always get something that responds to value.



41
42
43
# File 'lib/flipper/gate.rb', line 41

def wrap(thing)
  thing
end