Class: Flipper::Gate
- Inherits:
-
Object
- Object
- Flipper::Gate
- Extended by:
- Forwardable
- Defined in:
- lib/flipper/gate.rb
Direct Known Subclasses
Flipper::Gates::Actor, Flipper::Gates::Boolean, Flipper::Gates::Group, Flipper::Gates::PercentageOfActors, Flipper::Gates::PercentageOfRandom
Constant Summary collapse
- InstrumentationName =
Private: The name of instrumentation events.
"gate_operation.#{InstrumentationNamespace}"
Instance Attribute Summary collapse
-
#feature_name ⇒ Object
readonly
Private.
-
#instrumenter ⇒ Object
readonly
Private: What is used to instrument all the things.
Instance Method Summary collapse
- #data_type ⇒ Object
- #description(value) ⇒ Object
- #disable(thing) ⇒ Object
- #enable(thing) ⇒ Object
- #enabled?(value) ⇒ Boolean
-
#initialize(feature_name, options = {}) ⇒ Gate
constructor
Public.
-
#inspect ⇒ Object
Public: Pretty string version for debugging.
-
#instrument(operation, thing) ⇒ Object
Private.
-
#key ⇒ Object
Private: Name converted to value safe for adapter.
-
#name ⇒ Object
Public: The name of the gate.
-
#open?(thing) ⇒ Boolean
Internal: Check if a gate is open for a thing.
-
#protects?(thing) ⇒ Boolean
Internal: Check if a gate is protects a thing.
-
#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.
Constructor Details
#initialize(feature_name, options = {}) ⇒ Gate
Public
18 19 20 21 |
# File 'lib/flipper/gate.rb', line 18 def initialize(feature_name, = {}) @feature_name = feature_name @instrumenter = .fetch(:instrumenter, Flipper::Instrumenters::Noop) end |
Instance Attribute Details
#feature_name ⇒ Object (readonly)
Private
12 13 14 |
# File 'lib/flipper/gate.rb', line 12 def feature_name @feature_name end |
#instrumenter ⇒ Object (readonly)
Private: What is used to instrument all the things.
15 16 17 |
# File 'lib/flipper/gate.rb', line 15 def instrumenter @instrumenter end |
Instance Method Details
#data_type ⇒ Object
33 34 35 |
# File 'lib/flipper/gate.rb', line 33 def data_type raise 'Not implemented' end |
#description(value) ⇒ Object
49 50 51 |
# File 'lib/flipper/gate.rb', line 49 def description(value) raise 'Not implemented' end |
#disable(thing) ⇒ Object
41 42 43 |
# File 'lib/flipper/gate.rb', line 41 def disable(thing) raise 'Not implemented' end |
#enable(thing) ⇒ Object
37 38 39 |
# File 'lib/flipper/gate.rb', line 37 def enable(thing) raise 'Not implemented' end |
#enabled?(value) ⇒ Boolean
45 46 47 |
# File 'lib/flipper/gate.rb', line 45 def enabled?(value) raise 'Not implemented' end |
#inspect ⇒ Object
Public: Pretty string version for debugging.
74 75 76 77 78 79 |
# File 'lib/flipper/gate.rb', line 74 def inspect attributes = [ "feature_name=#{feature_name.inspect}", ] "#<#{self.class.name}:#{object_id} #{attributes.join(', ')}>" end |
#instrument(operation, thing) ⇒ Object
Private
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/flipper/gate.rb', line 82 def instrument(operation, thing) payload = { :thing => thing, :operation => operation, :gate_name => name, :feature_name => @feature_name, } @instrumenter.instrument(InstrumentationName, payload) { payload[:result] = yield(payload) if block_given? } end |
#key ⇒ Object
Private: Name converted to value safe for adapter. Implemented in subclass.
29 30 31 |
# File 'lib/flipper/gate.rb', line 29 def key raise 'Not implemented' end |
#name ⇒ Object
Public: The name of the gate. Implemented in subclass.
24 25 26 |
# File 'lib/flipper/gate.rb', line 24 def name raise 'Not implemented' end |
#open?(thing) ⇒ Boolean
Internal: Check if a gate is open for a thing. Implemented in subclass.
Returns true if gate open for thing, false if not.
56 57 58 |
# File 'lib/flipper/gate.rb', line 56 def open?(thing) 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.
63 64 65 |
# File 'lib/flipper/gate.rb', line 63 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.
69 70 71 |
# File 'lib/flipper/gate.rb', line 69 def wrap(thing) thing end |