Module: BackboneSync::Rails::Faye::Observer

Defined in:
lib/backbone_sync-rails/faye/observer.rb

Instance Method Summary collapse

Instance Method Details

#after_create(model) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/backbone_sync-rails/faye/observer.rb', line 15

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

#after_destroy(model) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/backbone_sync-rails/faye/observer.rb', line 23

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

#after_update(model) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/backbone_sync-rails/faye/observer.rb', line 7

def after_update(model)
  begin
    Event.new(model, :update).broadcast
  rescue *NET_HTTP_EXCEPTIONS => e
    handle_net_http_exception(e)
  end
end

#handle_net_http_exception(exception) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/backbone_sync-rails/faye/observer.rb', line 31

def handle_net_http_exception(exception)
  ::Rails.logger.error("")
  ::Rails.logger.error("Backbone::Sync::Rails::Faye::Observer encountered an exception:")
  ::Rails.logger.error(exception.class.name)
  ::Rails.logger.error(exception.message)
  ::Rails.logger.error(exception.backtrace.join("\n"))
  ::Rails.logger.error("")
end