Class: Seabright::Storage::Adapter
- Inherits:
-
Object
- Object
- Seabright::Storage::Adapter
- Defined in:
- lib/redis_object/storage/adapter.rb
Direct Known Subclasses
Instance Method Summary collapse
- #config ⇒ Object
- #config_opts(*opts) ⇒ Object
- #configure(conf) ⇒ Object
- #connection(num = 0) ⇒ Object
- #connections ⇒ Object
-
#initialize(config = {}) ⇒ Adapter
constructor
A new instance of Adapter.
- #new_connection ⇒ Object
- #reset ⇒ Object (also: #reconnect!)
Constructor Details
#initialize(config = {}) ⇒ Adapter
Returns a new instance of Adapter.
5 6 7 |
# File 'lib/redis_object/storage/adapter.rb', line 5 def initialize(config={}) configure config end |
Instance Method Details
#config ⇒ Object
14 15 16 |
# File 'lib/redis_object/storage/adapter.rb', line 14 def config @config ||= {} end |
#config_opts(*opts) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/redis_object/storage/adapter.rb', line 18 def config_opts(*opts) opts.inject({}) do |a,k| a[k] = config[k] a end end |
#configure(conf) ⇒ Object
9 10 11 12 |
# File 'lib/redis_object/storage/adapter.rb', line 9 def configure(conf) @config = conf reset end |
#connection(num = 0) ⇒ Object
32 33 34 |
# File 'lib/redis_object/storage/adapter.rb', line 32 def connection(num=0) connections[num] ||= new_connection end |
#connections ⇒ Object
36 37 38 |
# File 'lib/redis_object/storage/adapter.rb', line 36 def connections @connections ||= [] end |
#new_connection ⇒ Object
40 41 |
# File 'lib/redis_object/storage/adapter.rb', line 40 def new_connection end |
#reset ⇒ Object Also known as: reconnect!
25 26 27 28 29 |
# File 'lib/redis_object/storage/adapter.rb', line 25 def reset connections.each_index do |i| connections[i] = nil end end |