Class: Flipper::Gates::Actor
- Inherits:
-
Flipper::Gate
- Object
- Flipper::Gate
- Flipper::Gates::Actor
- Defined in:
- lib/flipper/gates/actor.rb
Constant Summary
Constants inherited from Flipper::Gate
Flipper::Gate::InstrumentationName
Instance Attribute Summary
Attributes inherited from Flipper::Gate
Instance Method Summary collapse
- #data_type ⇒ Object
- #description(value) ⇒ Object
- #enabled?(value) ⇒ Boolean
-
#key ⇒ Object
Internal: Name converted to value safe for adapter.
-
#name ⇒ Object
Internal: The name of the gate.
-
#open?(thing, value) ⇒ Boolean
Internal: Checks if the gate is open for a thing.
- #protects?(thing) ⇒ Boolean
- #wrap(thing) ⇒ Object
Methods inherited from Flipper::Gate
#disable, #enable, #initialize, #inspect, #instrument
Constructor Details
This class inherits a constructor from Flipper::Gate
Instance Method Details
#data_type ⇒ Object
14 15 16 |
# File 'lib/flipper/gates/actor.rb', line 14 def data_type :set end |
#description(value) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/flipper/gates/actor.rb', line 18 def description(value) if enabled?(value) actor_ids = value.to_a.sort.map { |id| id.inspect } "actors (#{actor_ids.join(', ')})" else 'disabled' end end |
#enabled?(value) ⇒ Boolean
27 28 29 |
# File 'lib/flipper/gates/actor.rb', line 27 def enabled?(value) !value.nil? && !value.empty? end |
#key ⇒ Object
Internal: Name converted to value safe for adapter.
10 11 12 |
# File 'lib/flipper/gates/actor.rb', line 10 def key :actors end |
#name ⇒ Object
Internal: The name of the gate. Used for instrumentation, etc.
5 6 7 |
# File 'lib/flipper/gates/actor.rb', line 5 def name :actor end |
#open?(thing, value) ⇒ Boolean
Internal: Checks if the gate is open for a thing.
Returns true if gate open for thing, false if not.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/flipper/gates/actor.rb', line 34 def open?(thing, value) instrument(:open?, thing) { |payload| if thing.nil? false else if protects?(thing) actor = wrap(thing) enabled_actor_ids = value enabled_actor_ids.include?(actor.value) else false end end } end |
#protects?(thing) ⇒ Boolean
54 55 56 |
# File 'lib/flipper/gates/actor.rb', line 54 def protects?(thing) Types::Actor.wrappable?(thing) end |