Skip to content

Commit

Permalink
Extract method refactor on Faye::Observer
Browse files Browse the repository at this point in the history
  • Loading branch information
patricksrobertson committed Mar 7, 2012
1 parent 5ce197e commit 9b67e23
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions lib/backbone_sync-rails/faye/observer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,25 @@ module Rails
module Faye
module Observer
def after_update(model)
Event.new(model, :update).broadcast
rescue *NET_HTTP_EXCEPTIONS => e
handle_net_http_exception(e)
handle_event(model, :update)
end

def after_create(model)
Event.new(model, :create).broadcast
rescue *NET_HTTP_EXCEPTIONS => e
handle_net_http_exception(e)
handle_event(model, :create)
end

def after_destroy(model)
Event.new(model, :destroy).broadcast
rescue *NET_HTTP_EXCEPTIONS => e
handle_net_http_exception(e)
handle_event(model, :destroy)
end

def after_touch(model)
Event.new(model, :update).broadcast
handle_event(model, :touch)
end

def handle_event(model, event)
Event.new(model, event).broadcast
rescue *NET_HTTP_EXCEPTIONS => e
handle_net_http_exception(e)
handle_net_http_exception e
end

def handle_net_http_exception(exception)
Expand Down

0 comments on commit 9b67e23

Please sign in to comment.