Class: Flipper::Gate

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

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Gate

Public



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

def initialize(options = {})
end

Instance Method Details

#data_typeObject



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

def data_type
  raise 'Not implemented'
end

#enabled?(value) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/flipper/gate.rb', line 25

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

#inspectObject

Public: Pretty string version for debugging.



50
51
52
53
54
55
56
57
# File 'lib/flipper/gate.rb', line 50

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.



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

def key
  raise 'Not implemented'
end

#nameObject

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



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

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)


32
33
34
# File 'lib/flipper/gate.rb', line 32

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)


39
40
41
# File 'lib/flipper/gate.rb', line 39

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.



45
46
47
# File 'lib/flipper/gate.rb', line 45

def wrap(thing)
  thing
end