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
- #description ⇒ Object
- #disable(thing) ⇒ Object
- #enable(thing) ⇒ Object
-
#key ⇒ Object
Internal: The piece of the adapter key that is unique to the gate class.
-
#name ⇒ Object
Internal: The name of the gate.
-
#open?(thing) ⇒ Boolean
Internal: Checks if the gate is open for a thing.
- #protects?(thing) ⇒ Boolean
-
#toggle_class ⇒ Object
Internal: The toggle class used to enable/disable the gate for a thing.
Methods inherited from Flipper::Gate
#adapter_key, #enabled?, #initialize, #inspect, #instrument, #toggle
Constructor Details
This class inherits a constructor from Flipper::Gate
Instance Method Details
#description ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/flipper/gates/actor.rb', line 50 def description if enabled? "actors (#{toggle.value.to_a.sort.join(', ')})" else 'disabled' end end |
#disable(thing) ⇒ Object
46 47 48 |
# File 'lib/flipper/gates/actor.rb', line 46 def disable(thing) super Types::Actor.wrap(thing) end |
#enable(thing) ⇒ Object
42 43 44 |
# File 'lib/flipper/gates/actor.rb', line 42 def enable(thing) super Types::Actor.wrap(thing) end |
#key ⇒ Object
Internal: The piece of the adapter key that is unique to the gate class.
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) ⇒ Boolean
Internal: Checks if the gate is open for a thing.
Returns true if gate open for thing, false if not.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/flipper/gates/actor.rb', line 22 def open?(thing) instrument(:open?, thing) { |payload| if thing.nil? false else if Types::Actor.wrappable?(thing) actor = Types::Actor.wrap(thing) enabled_actor_ids = toggle.value enabled_actor_ids.include?(actor.value) else false end end } end |
#protects?(thing) ⇒ Boolean
38 39 40 |
# File 'lib/flipper/gates/actor.rb', line 38 def protects?(thing) Types::Actor.wrappable?(thing) end |