Class: Miniswitch::Switcher
- Inherits:
-
Object
- Object
- Miniswitch::Switcher
- Defined in:
- lib/miniswitch/switcher.rb
Instance Method Summary collapse
- #group(name) ⇒ Object
-
#initialize(redis_url, prefix, pool_size: 4) ⇒ Switcher
constructor
A new instance of Switcher.
- #prefix_slug ⇒ Object
- #root ⇒ Object
- #with_redis(&b) ⇒ Object
Constructor Details
#initialize(redis_url, prefix, pool_size: 4) ⇒ Switcher
Returns a new instance of Switcher.
4 5 6 7 8 9 |
# File 'lib/miniswitch/switcher.rb', line 4 def initialize(redis_url, prefix, pool_size: 4) @prefix = prefix @redis = ConnectionPool.new(size: pool_size, timeout: 5) do Redis.new(url: redis_url) end end |
Instance Method Details
#group(name) ⇒ Object
15 16 17 |
# File 'lib/miniswitch/switcher.rb', line 15 def group(name) Miniswitch::Group.new(self, name, nil) end |
#prefix_slug ⇒ Object
23 24 25 |
# File 'lib/miniswitch/switcher.rb', line 23 def prefix_slug @prefix ? [@prefix] : [] end |
#root ⇒ Object
19 20 21 |
# File 'lib/miniswitch/switcher.rb', line 19 def root group(nil) end |
#with_redis(&b) ⇒ Object
11 12 13 |
# File 'lib/miniswitch/switcher.rb', line 11 def with_redis(&b) @redis.with(&b) end |