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.



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

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?(actors, value, options = {}) ⇒ Boolean

Internal: Check if a gate is open for one or more actors. Implemented in subclass.

Returns true if gate open for any actor, false if not.

Returns:

  • (Boolean)


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

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

#protects?(actor) ⇒ Boolean

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

Returns true if gate protects actor, false if not.

Returns:

  • (Boolean)


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

def protects?(actor)
  false
end

#wrap(actor) ⇒ Object

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



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

def wrap(actor)
  actor
end