[PATCH]Hooks and STI
Reported by Guillaume Maury (giom) | May 13th, 2008 @ 04:35 AM
When you add a before hook in a superclass, it doesn't work in the super class.
For example
class User
include DataMapper::Resource
property :type, Class, :default => lambda {|*args| args[0].class.to_s}
before :save, :do_something
def do_something
puts "hello"
end
end
class Member < User
def do_something
puts "member"
end
end
>>User.new.save
"hello"
=> true
>>Guest.new.save
undefined method `call' for nil:NilClass
/Users/hiorin/git/dm-core/lib/data_mapper/hook.rb:111:in `a_class_method'
/Users/hiorin/git/dm-core/spec/unit/hook_spec.rb:64:
The patch included solves this problem and adds two badly named spec to check it...
You can also pull it with git pull git://github.com/giom/dm-core.git hooks
Comments and changes to this ticket
-
Alex Coles May 13th, 2008 @ 01:19 PM
I applied the patch in the following commit:
http://github.com/sam/dm-core/co...
My apologies - I did not properly credit your commit.
-

-
Alex Coles May 14th, 2008 @ 03:20 AM
Thanks for the patch! I missed a flag on git commit!
This can now be marked as RESOLVED.
-
Adam French May 14th, 2008 @ 01:29 PM
- → State changed from new to resolved
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
