Skip to content

Commit

Permalink
Define callback so chain is not emtpy
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurnn committed Jun 4, 2014
1 parent f4560f1 commit b82ad9a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/mongoid/interceptable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,12 @@ def run_targeted_callbacks(place, kind)
if Gem::Version.new("4.1.0") <= Gem::Version.new(ActiveSupport::VERSION::STRING)
self.class.send :define_method, name do
runner = ActiveSupport::Callbacks::Filters::Environment.new(self, false, nil)
chain.compile.call(runner)
chain.compile.call(runner).value
end
self.class.send :protected, name
else
class_eval <<-EOM
def #{name}()
def #{name}()
#{chain.compile}
end
protected :#{name}
Expand Down
1 change: 1 addition & 0 deletions spec/mongoid/interceptable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ class TestClass

before(:all) do
Band.define_model_callbacks(:rearrange)
Band.after_rearrange { }
end

after(:all) do
Expand Down

0 comments on commit b82ad9a

Please sign in to comment.