Class: Warren::Queue
- Inherits:
-
Object
- Object
- Warren::Queue
- Defined in:
- lib/warren/queue.rb,
lib/warren/adapters/bunny_adapter.rb
Direct Known Subclasses
Defined Under Namespace
Classes: AMQPAdapter, BunnyAdapter
Constant Summary collapse
- NoConnectionDetails =
Raised if no connection has been defined yet.
Class.new(Exception)
- NoBlockGiven =
Raised if a block is expected by the method but none is given.
Class.new(Exception)
- NoAdapterSet =
Raised if an adapter isn’t set
Class.new(Exception)
- InvalidAdapter =
Raised if the adapter is missing a method Check the message for details of the missing method.
Class.new(Exception)
- @@connection =
nil
- @@adapter =
nil
- @@logger =
nil
Class Method Summary collapse
-
.adapter ⇒ Object
Returns the current adapter or raises NoAdapterSet exception.
-
.adapter=(klass) ⇒ Object
Sets the adapter manually.
-
.connection ⇒ Object
Returns the current connection details.
-
.connection=(conn) ⇒ Object
Sets the current connection.
-
.inherited(klass) ⇒ Object
Sets the adapter when this class is subclassed.
- .logger ⇒ Object
- .logger=(l) ⇒ Object
-
.publish(*args, &blk) ⇒ Object
Publishes the message to the queue.
-
.subscribe(*args, &blk) ⇒ Object
Sends the subscribe message to the adapter class.
Class Method Details
.adapter ⇒ Object
Returns the current adapter or raises NoAdapterSet exception
59 60 61 |
# File 'lib/warren/queue.rb', line 59 def self.adapter @@adapter || raise(NoAdapterSet) end |
.adapter=(klass) ⇒ Object
Sets the adapter manually
52 53 54 |
# File 'lib/warren/queue.rb', line 52 def self.adapter= klass @@adapter = klass end |
.connection ⇒ Object
Returns the current connection details
38 39 40 |
# File 'lib/warren/queue.rb', line 38 def self.connection @@connection ||= Warren::Connection.new end |
.connection=(conn) ⇒ Object
Sets the current connection
31 32 33 |
# File 'lib/warren/queue.rb', line 31 def self.connection= conn @@connection = (conn.is_a?(Warren::Connection) ? conn : Warren::Connection.new(conn) ) end |
.inherited(klass) ⇒ Object
Sets the adapter when this class is subclassed.
45 46 47 |
# File 'lib/warren/queue.rb', line 45 def self.inherited klass @@adapter = klass end |
.logger ⇒ Object
79 80 81 82 83 84 |
# File 'lib/warren/queue.rb', line 79 def self.logger unless @@logger @@logger = Logger.new(nil) end @@logger end |
.logger=(l) ⇒ Object
86 87 88 |
# File 'lib/warren/queue.rb', line 86 def self.logger=(l) @@logger = l end |
.publish(*args, &blk) ⇒ Object
Publishes the message to the queue
66 67 68 69 |
# File 'lib/warren/queue.rb', line 66 def self.publish *args, &blk raise(InvalidAdapter, "publish method missing") unless @@adapter.respond_to?(:publish) self.adapter.publish(*args, &blk) end |
.subscribe(*args, &blk) ⇒ Object
Sends the subscribe message to the adapter class
74 75 76 77 |
# File 'lib/warren/queue.rb', line 74 def self.subscribe *args, &blk raise(InvalidAdapter.new("subscribe method missing")) unless @@adapter.respond_to?(:subscribe) self.adapter.subscribe(*args, &blk) end |