Created
February 5, 2013 03:07
-
-
Save sxross/4711848 to your computer and use it in GitHub Desktop.
Super in module context
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MotionModel | |
module Model | |
def save(*) | |
puts "called MM#save" | |
end | |
end | |
end | |
module MotionModel | |
module Paranoid | |
def save(paranoid = false) | |
puts paranoid ? "called Paranoid save" : super | |
end | |
end | |
end | |
class MyModel | |
include MotionModel | |
include Paranoid | |
end | |
model = MyModel.new | |
model.save | |
model.save(true) |
This reassembles more closely to what we have in MotionModel::Paranoid: https://gist.github.com/ivanacostarubio/4711920
The first: model.save fail because of validations. The second model.save(true) valls the save method in MotionModel::Model because it passed the validations.
Maybe there is something that I am not seing. Thank you for helping me understand it. :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey!
I run that code and I get http://pastie.org/private/zud0x6kz73ckytlnwng8q
however, I am running it on 1.9.3.