em_remote_call 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/em_remote_call/client.rb +5 -2
- data/lib/em_remote_call/server.rb +1 -5
- data/lib/em_remote_call/version.rb +1 -1
- data/spec/integration_spec.rb +18 -1
- metadata +2 -2
@@ -8,7 +8,10 @@ module EM::RemoteCall
|
|
8
8
|
end
|
9
9
|
|
10
10
|
define_method name do |*method_opts, &callb|
|
11
|
-
|
11
|
+
remote_connection =
|
12
|
+
(self.class.respond_to?(:remote_connection) && self.class.remote_connection) ||
|
13
|
+
(self.respond_to?(:remote_connection) && self.remote_connection)
|
14
|
+
return unless remote_connection
|
12
15
|
|
13
16
|
callback = EM::RemoteCall::Deferrable.new
|
14
17
|
callback.callback(&callb) if callb
|
@@ -23,7 +26,7 @@ module EM::RemoteCall
|
|
23
26
|
:deferrable_id => callback.object_id # store the callbacks object_id to retrieve it later
|
24
27
|
}
|
25
28
|
|
26
|
-
|
29
|
+
remote_connection.call call
|
27
30
|
return callback
|
28
31
|
end
|
29
32
|
end
|
@@ -23,11 +23,7 @@ class EM::RemoteCall::Call
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def call(&callb)
|
26
|
-
|
27
|
-
@instance.__send__ @method, @argument, &callb
|
28
|
-
else
|
29
|
-
@instance.__send__ @method, &callb
|
30
|
-
end
|
26
|
+
@argument ? @instance.__send__(@method, @argument, &callb) : @instance.__send__(@method, &callb)
|
31
27
|
end
|
32
28
|
end
|
33
29
|
|
data/spec/integration_spec.rb
CHANGED
@@ -28,7 +28,10 @@ class ServerTrack < Track
|
|
28
28
|
"started #{id}"
|
29
29
|
end
|
30
30
|
def raise_hell
|
31
|
-
|
31
|
+
raise 'foobar'
|
32
|
+
end
|
33
|
+
def self.some_class_meth
|
34
|
+
yield
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
@@ -37,6 +40,11 @@ class ClientTrack < Track
|
|
37
40
|
remote_method :init_track_on_server, :class_name => 'ServerTrack', :calls => :new
|
38
41
|
remote_method :play, :class_name => 'ServerTrack', :find_by => :id
|
39
42
|
remote_method :raise_hell, :class_name => 'ServerTrack', :find_by => :id
|
43
|
+
|
44
|
+
class << self
|
45
|
+
extend EM::RemoteCall
|
46
|
+
remote_method :some_class_meth, :class_name => 'ServerTrack'
|
47
|
+
end
|
40
48
|
end
|
41
49
|
|
42
50
|
class EMController
|
@@ -94,4 +102,13 @@ describe EM::RemoteCall do
|
|
94
102
|
end
|
95
103
|
end
|
96
104
|
end
|
105
|
+
describe "client side class method" do
|
106
|
+
it "should work :)" do
|
107
|
+
test_on_client do
|
108
|
+
callb = mock(:callb)
|
109
|
+
callb.should_receive(:foo)
|
110
|
+
ClientTrack.some_class_meth{callb.foo}
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
97
114
|
end
|