jwkoelewijn/batsir — pull request #19 by czarneckid (2013-07-26 13:12:46+00:00)
Title: Fix conditional notifiers

In trying to use conditional notifiers, I noticed it was blowing up with an error similar to the following:

```
WARN batsir: Caught NoMethodError: undefined method `new' for #
/Users/dczarnecki/projects/batsir/lib/batsir/notifiers/conditional_notifier.rb:23:in `block in execute'
/Users/dczarnecki/projects/batsir/lib/batsir/notifiers/conditional_notifier.rb:18:in `each'
/Users/dczarnecki/projects/batsir/lib/batsir/notifiers/conditional_notifier.rb:18:in `execute'
/Users/dczarnecki/projects/batsir/lib/batsir/notifiers/notifier.rb:24:in `notify'
/Users/dczarnecki/projects/batsir/lib/batsir/stage_worker.rb:24:in `block in execute'
/Users/dczarnecki/projects/batsir/lib/batsir/stage_worker.rb:23:in `each'
/Users/dczarnecki/projects/batsir/lib/batsir/stage_worker.rb:23:in `execute'
```

I printed out the generated code and noticed the following:

```
def self.initialize_filter_queue
@filter_queue = Batsir::FilterQueue.new
@filter_queue.add MyModule::Filters::StatisticsFilter.new({})
@filter_queue.add MyModule::Filters::NoopFilter.new({})
conditional_notifier = Batsir::Notifiers::ConditionalNotifier.new
condition = ->(message){2 > 1}
conditional_notifier.add_notifier condition, MyModule::Notifiers::TrueNotifier.new({})
conditional_notifier.add_transformer Batsir::Transformers::JSONOutputTransformer.new
@filter_queue.add_notifier conditional_notifier
end
```

So the generated code is already instantiating an instance of the notifier class to the `add_notifier` method.

* The `ConditionalNotifierDeclaration#compile` method instantiates
an instance of the notifier, so do not try and `new` the
instance again.
* Update specs to reflect what the `ConditionalNotifierDeclaration#compile`
method is doing behind the scenes.