Last active
November 29, 2015 19:11
-
-
Save mehlah/81f0351b1e761d88800b to your computer and use it in GitHub Desktop.
Alias Method Chain
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
require 'active_support/all' | |
class Record | |
def save | |
p 'saved!' | |
end | |
def save_with_validation | |
p 'validated!' | |
save_without_validation | |
end | |
alias_method_chain :save, :validation | |
end | |
Record.new.save | |
#=> "validated!" | |
#=> "saved!" | |
Record.new.save_without_validation | |
#=> "saved!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment