bscofield/watership — pull request #3 by daniel-marschner (2014-01-29 14:34:25+00:00)
Title: Added the `Watership::Subscriber` module

This `Watership::Subscriber` module gives you the base functionality for subscribing to a specific queue you are enqueuing messages to. To Create your own subscriber you just need to create a new class and include the `Watership::Subscriber` and define the `.perform` method. Here is an example:

```ruby
require "watership/subscriber"

class MySubscriber
include Watership::Subscriber

def perform(payload)
# Here you define the logic you want to execute for every message you retrieve.
# The payload includes the actual content you have send while enqueuing.
end
end
```

Subscribing to your queue is pretty simple, just do the following lines and you're good to go:

```ruby
subscriber = MySubscriber.new
subscriber.subscribe("the.name.of.the.queue")
```

The `.subscribe` method also gives you the possibility to add Bunny/RabbitMQ options to your subscription as second parameter.