backbone_sync-rails 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
data/lib/backbone_sync-rails.rb
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
require 'backbone_sync-rails/faye'
|
2
2
|
|
3
|
-
module
|
4
|
-
|
3
|
+
module BackboneSync
|
4
|
+
module Rails
|
5
|
+
NET_HTTP_EXCEPTIONS = [Timeout::Error, Errno::ETIMEDOUT, Errno::EINVAL,
|
6
|
+
Errno::ECONNRESET, Errno::ECONNREFUSED, EOFError,
|
7
|
+
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
|
8
|
+
Net::ProtocolError]
|
9
|
+
|
10
|
+
class Engine < ::Rails::Engine
|
11
|
+
end
|
5
12
|
end
|
6
13
|
end
|
@@ -5,15 +5,36 @@ module BackboneSync
|
|
5
5
|
module Faye
|
6
6
|
module Observer
|
7
7
|
def after_update(model)
|
8
|
-
|
8
|
+
begin
|
9
|
+
Event.new(model, :update).broadcast
|
10
|
+
rescue *NET_HTTP_EXCEPTIONS => e
|
11
|
+
handle_net_http_exception(e)
|
12
|
+
end
|
9
13
|
end
|
10
14
|
|
11
15
|
def after_create(model)
|
12
|
-
|
16
|
+
begin
|
17
|
+
Event.new(model, :create).broadcast
|
18
|
+
rescue *NET_HTTP_EXCEPTIONS => e
|
19
|
+
handle_net_http_exception(e)
|
20
|
+
end
|
13
21
|
end
|
14
22
|
|
15
23
|
def after_destroy(model)
|
16
|
-
|
24
|
+
begin
|
25
|
+
Event.new(model, :destroy).broadcast
|
26
|
+
rescue *NET_HTTP_EXCEPTIONS => e
|
27
|
+
handle_net_http_exception(e)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def handle_net_http_exception(exception)
|
32
|
+
::Rails.logger.error("")
|
33
|
+
::Rails.logger.error("Backbone::Sync::Rails::Faye::Observer encountered an exception:")
|
34
|
+
::Rails.logger.error(exception.class.name)
|
35
|
+
::Rails.logger.error(exception.message)
|
36
|
+
::Rails.logger.error(exception.backtrace.join("\n"))
|
37
|
+
::Rails.logger.error("")
|
17
38
|
end
|
18
39
|
end
|
19
40
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: backbone_sync-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.8
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jason Morrison
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-09-
|
13
|
+
date: 2011-09-29 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -97,7 +97,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
97
97
|
requirements:
|
98
98
|
- - ">="
|
99
99
|
- !ruby/object:Gem::Version
|
100
|
-
hash:
|
100
|
+
hash: 536978806733157496
|
101
101
|
segments:
|
102
102
|
- 0
|
103
103
|
version: "0"
|
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
requirements:
|
107
107
|
- - ">="
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
hash:
|
109
|
+
hash: 536978806733157496
|
110
110
|
segments:
|
111
111
|
- 0
|
112
112
|
version: "0"
|