Created
April 19, 2010 13:20
-
-
Save pedromtavares/371033 to your computer and use it in GitHub Desktop.
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 PrecoReal | |
def self.included( base ) | |
@base = base | |
end | |
def atributo_em_real(*args) | |
args.each do |arg| | |
@base.class_eval %Q! | |
def #{arg}_with_real | |
self.#{arg}.real if self.#{arg} | |
end | |
alias_method_chain #{arg}, :real | |
def #{arg}_with_real=(novo) | |
self.#{arg} = novo | |
end | |
alias_method_chain #{arg}, :real= | |
Q! | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment