Created
May 13, 2012 10:31
-
-
Save pechorin/2687648 to your computer and use it in GitHub Desktop.
proxy
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
class Image | |
def after_save | |
puts "after save image!" | |
end | |
end | |
img = Image.new | |
img.after_save # => "after save image!" | |
# а теперь прокся :D | |
Image.class_eval do | |
def after_save_proxy | |
old_after_save | |
puts "this is proxy call! :)" | |
end | |
alias :old_after_save :after_save | |
alias :after_save :after_save_proxy | |
end | |
img_with_proxy = Image.new | |
img_with_proxy.after_save # => "after save image!" | |
# => "this is proxy call! :)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment