class Batsir::Notifiers::Notifier
Attributes
field_mapping[RW]
transformer_queue[RW]
Public Class Methods
new(options = {})
click to toggle source
# File lib/batsir/notifiers/notifier.rb, line 7 def initialize(options = {}) fields = options.delete(:fields) options.each do |option, value| self.send("#{option}=", value) end @transformer_queue = [] if fields add_transformer(Batsir::Transformers::FieldTransformer.new(:fields => fields)) end end
Public Instance Methods
add_transformer(transformer)
click to toggle source
# File lib/batsir/notifiers/notifier.rb, line 19 def add_transformer(transformer) @transformer_queue << transformer end
execute(message)
click to toggle source
# File lib/batsir/notifiers/notifier.rb, line 35 def execute(message) raise NotImplementedError.new end
notify(message)
click to toggle source
# File lib/batsir/notifiers/notifier.rb, line 23 def notify(message) execute(transform(message.clone)) message end
transform(message)
click to toggle source
# File lib/batsir/notifiers/notifier.rb, line 28 def transform(message) transformer_queue.each do |transformer| message = transformer.transform(message) end message end