Skip to content

Commit

Permalink
Merge pull request #575 from abstractive/e2-fix_554_synchronous_call
Browse files Browse the repository at this point in the history
add missing block param in SyncCall (#554)
  • Loading branch information
//de committed Apr 12, 2015
2 parents 9570440 + 96dbce4 commit 7d6211d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
6 changes: 1 addition & 5 deletions lib/celluloid/proxies/sync_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,9 @@ def method_missing(meth, *args, &block)

if @mailbox == ::Thread.current[:celluloid_mailbox]
args.unshift meth
meth = :__send__
=begin
TODO: Revisit #554
actor = Thread.current[:celluloid_actor]
actor = actor.behavior.subject.bare_object
return actor.__send__(*args)
=end
return actor.__send__(*args, &block)
end

call = SyncCall.new(::Celluloid.mailbox, meth, args, block)
Expand Down
21 changes: 21 additions & 0 deletions spec/celluloid/actor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,27 @@
expect(actor.greet).to eq("Hi, I'm Troy McClure")
end

context "with a method accepting a block" do
let(:actor) { james_bond_role.new }
let(:james_bond_role) do
Class.new do
include CelluloidSpecs.included_module
def act
"My name is #{yield("James", "Bond")}"
end

def give_role_to(actor, &block)
actor.act(&block)
end
end
end

it "supports synchronously passing a block to itself through a reference" do
result = actor.give_role_to(actor) { |name, surname| "#{surname}. #{name} #{surname}." }
expect(result).to eq("My name is Bond. James Bond.")
end
end

it "supports synchronous calls via #method" do
method = actor.method(:greet)
expect(method.call).to eq("Hi, I'm Troy McClure")
Expand Down

0 comments on commit 7d6211d

Please sign in to comment.