Skip to content

Commit 35e3cf0

Browse files
Remove Proxy#respond_to_missing? as it seems unnecesary.
1 parent a1812d6 commit 35e3cf0

File tree

4 files changed

+19
-53
lines changed

4 files changed

+19
-53
lines changed

lib/async/bus/protocol/proxy.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,6 @@ def respond_to?(name, include_all = false)
6868
@connection.invoke(@name, [:respond_to?, name, include_all])
6969
end
7070

71-
# Check if the remote object responds to a missing method.
72-
# @parameter name [Symbol] The method name to check.
73-
# @parameter include_all [Boolean] Whether to include private methods.
74-
# @returns [Boolean] True if the method exists.
75-
def respond_to_missing?(name, include_all = false)
76-
@connection.invoke(@name, [:respond_to?, name, include_all])
77-
end
78-
7971
# Return a string representation of the proxy.
8072
# @returns [String] A string describing the proxy.
8173
def inspect

lib/async/bus/protocol/transaction.rb

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -90,27 +90,27 @@ def invoke(name, arguments, options, &block)
9090

9191
self.write(Invoke.new(@id, name, arguments, options, block_given?))
9292

93-
while response = self.read
94-
case response
95-
when Return
96-
return response.result
97-
when Yield
98-
begin
99-
result = yield(*response.result)
100-
self.write(Next.new(@id, result))
101-
rescue => error
102-
self.write(Error.new(@id, error))
93+
while response = self.read
94+
case response
95+
when Return
96+
return response.result
97+
when Yield
98+
begin
99+
result = yield(*response.result)
100+
self.write(Next.new(@id, result))
101+
rescue => error
102+
self.write(Error.new(@id, error))
103+
end
104+
when Error
105+
raise(response.result)
106+
when Throw
107+
# Re-throw the tag and value that was thrown on the server side
108+
# Throw.result contains [tag, value] array
109+
tag, value = response.result
110+
throw(tag, value)
103111
end
104-
when Error
105-
raise(response.result)
106-
when Throw
107-
# Re-throw the tag and value that was thrown on the server side
108-
# Throw.result contains [tag, value] array
109-
tag, value = response.result
110-
throw(tag, value)
111112
end
112113
end
113-
end
114114

115115
# Accept a remote procedure invocation.
116116
# @parameter object [Object] The object to invoke the method on.

test/async/bus/protocol/connection.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def get_temporary_object
208208
# Break as soon as the object is no longer in the server's objects:
209209
break unless server_connection.objects.key?(name)
210210
end
211-
211+
212212
expect(server_connection.objects).not.to have_keys(name)
213213
end
214214
end

test/async/bus/protocol/proxy.rb

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,5 @@ def service.!
2727
end
2828
end
2929
end
30-
31-
with "#respond_to_missing?" do
32-
it "can check if remote object responds to method" do
33-
start_server do |connection|
34-
service = Object.new
35-
def service.test_method
36-
:result
37-
end
38-
39-
connection.bind(:service, service)
40-
end
41-
42-
client.connect do |connection|
43-
proxy = connection[:service]
44-
45-
# Call respond_to_missing? using instance_eval since Proxy inherits from BasicObject
46-
# which doesn't have send/__send__/method
47-
# (respond_to? is defined on Proxy, so Ruby won't call respond_to_missing? automatically)
48-
result1 = proxy.instance_eval { respond_to_missing?(:test_method, false) }
49-
result2 = proxy.instance_eval { respond_to_missing?(:nonexistent_method, false) }
50-
51-
expect(result1).to be == true
52-
expect(result2).to be == false
53-
end
54-
end
55-
end
5630
end
5731

0 commit comments

Comments
 (0)