Class: RosettaQueue::Adapter
- Inherits:
-
Object
- Object
- RosettaQueue::Adapter
- Defined in:
- lib/rosetta_queue/adapter.rb
Class Attribute Summary collapse
-
.host ⇒ Object
writeonly
Sets the attribute host.
-
.options ⇒ Object
writeonly
Sets the attribute options.
-
.password ⇒ Object
writeonly
Sets the attribute password.
-
.port ⇒ Object
writeonly
Sets the attribute port.
-
.user ⇒ Object
writeonly
Sets the attribute user.
Class Method Summary collapse
- .define {|_self| ... } ⇒ Object
-
.open ⇒ Object
Yield a new (connected) adapter, run whatever is in the block, and then disconnect after the block evaluates.
- .reset ⇒ Object
- .type=(adapter_prefix) ⇒ Object
Class Attribute Details
.host=(value) ⇒ Object (writeonly)
Sets the attribute host
7 8 9 |
# File 'lib/rosetta_queue/adapter.rb', line 7 def host=(value) @host = value end |
.options=(value) ⇒ Object (writeonly)
Sets the attribute options
7 8 9 |
# File 'lib/rosetta_queue/adapter.rb', line 7 def (value) @options = value end |
.password=(value) ⇒ Object (writeonly)
Sets the attribute password
7 8 9 |
# File 'lib/rosetta_queue/adapter.rb', line 7 def password=(value) @password = value end |
.port=(value) ⇒ Object (writeonly)
Sets the attribute port
7 8 9 |
# File 'lib/rosetta_queue/adapter.rb', line 7 def port=(value) @port = value end |
.user=(value) ⇒ Object (writeonly)
Sets the attribute user
7 8 9 |
# File 'lib/rosetta_queue/adapter.rb', line 7 def user=(value) @user = value end |
Class Method Details
.define {|_self| ... } ⇒ Object
9 10 11 |
# File 'lib/rosetta_queue/adapter.rb', line 9 def define yield self end |
.open ⇒ Object
Yield a new (connected) adapter, run whatever is in the block, and then disconnect after the block evaluates
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rosetta_queue/adapter.rb', line 27 def open raise AdapterException, "Adapter type was never defined!" unless @adapter_class adapter = @adapter_class.new({:user => @user, :password => @password, :host => @host, :port => @port, :opts => opts}) if block_given? begin yield adapter ensure adapter.disconnect end end adapter end |
.reset ⇒ Object
13 14 15 |
# File 'lib/rosetta_queue/adapter.rb', line 13 def reset @user, @password, @host, @port, @options, @adapter_class = nil, nil, nil, nil, nil, nil end |
.type=(adapter_prefix) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/rosetta_queue/adapter.rb', line 17 def type=(adapter_prefix) require "rosetta_queue/adapters/#{adapter_prefix}" @adapter_class = RosettaQueue::Gateway.const_get("#{adapter_prefix.to_s.classify}Adapter") rescue LoadError raise AdapterException, "Adapter type '#{adapter_prefix}' does not match existing adapters!" end |