Class: Sheetah::BackendsRegistry
- Inherits:
-
Object
- Object
- Sheetah::BackendsRegistry
- Defined in:
- lib/sheetah/backends_registry.rb
Instance Method Summary collapse
- #freeze ⇒ Object
- #get(*args, **opts) ⇒ Object
-
#initialize ⇒ BackendsRegistry
constructor
A new instance of BackendsRegistry.
- #set(backend, &matcher) ⇒ Object
Constructor Details
#initialize ⇒ BackendsRegistry
Returns a new instance of BackendsRegistry.
5 6 7 |
# File 'lib/sheetah/backends_registry.rb', line 5 def initialize @registry = {} end |
Instance Method Details
#freeze ⇒ Object
22 23 24 25 |
# File 'lib/sheetah/backends_registry.rb', line 22 def freeze @registry.freeze super end |
#get(*args, **opts) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/sheetah/backends_registry.rb', line 14 def get(*args, **opts) @registry.each do |backend, matcher| return backend if matcher.call(args, opts) end nil end |
#set(backend, &matcher) ⇒ Object
9 10 11 12 |
# File 'lib/sheetah/backends_registry.rb', line 9 def set(backend, &matcher) @registry[backend] = matcher self end |