class Redispatcher::Dispatcher

Attributes

instance[RW]
object[RW]
options[RW]
processed_object[RW]

Public Class Methods

dispatch(object, options={}) click to toggle source
# File lib/redispatcher/dispatcher.rb, line 49
def dispatch(object, options={})
  @instance = new(object, options)

  begin
    instance.process
  rescue DispatcherSuppressedError => e
    instance.log e
    return nil
  end

  begin
    return instance.commit
  rescue Exception => e
    instance.log e
    instance.rollback
    raise e
  end
end
new(object, options={}) click to toggle source
# File lib/redispatcher/dispatcher.rb, line 19
def initialize(object, options={})
  @object = object
  @options = options
  run_dispatcher_callbacks :initialize do
    log "initialize callback"
  end
end

Public Instance Methods

commit() click to toggle source
# File lib/redispatcher/dispatcher.rb, line 33
def commit
  run_dispatcher_callbacks :commit do
    log "commit callback"
  end
  processed_object
end
process() click to toggle source
# File lib/redispatcher/dispatcher.rb, line 27
def process
  run_dispatcher_callbacks :process do
    log "process callback"
  end
end
rollback() click to toggle source
# File lib/redispatcher/dispatcher.rb, line 40
def rollback
  run_dispatcher_callbacks :rollback do
    log "rollback callback"
  end
end