Skip to content

Commit

Permalink
fixed bug where after callbacks wouldn't get run if method returned f…
Browse files Browse the repository at this point in the history
…alse
  • Loading branch information
nakajima committed Nov 14, 2008
1 parent 72ed19e commit f637891
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/booty_call/callbacker.rb
Expand Up @@ -52,7 +52,7 @@ def #{method_id}(*args, &block)
catch(#{method_id.to_sym.inspect}) do
result = nil
return unless run_callbacks(:before, #{method_id.inspect})
return unless run_callbacks(:around, #{method_id.inspect}) do
run_callbacks(:around, #{method_id.inspect}) do
result = __PRISTINE__(#{method_id.inspect}, *args, &block)
end
run_callbacks(:after, #{method_id.inspect}, result)
Expand Down
8 changes: 7 additions & 1 deletion spec/callbacker_spec.rb
Expand Up @@ -353,6 +353,12 @@ def pitch
object.foo
object.results.should == [:foo]
end

it "still gets called when method returns false" do
callbacker.after(:bar?) { @results << :called }
object.bar?(:foo)
object.results.should == [false, :called]
end

it "can be more than one per method" do
callbacker.after(:foo) { ping! }
Expand Down Expand Up @@ -419,7 +425,7 @@ def pitch
object.foo
object.results.should == [:foo]
end

it "gets access to result of method call" do
callbacker.after(:foo, :bar)

Expand Down

0 comments on commit f637891

Please sign in to comment.