Skip to content

Instantly share code, notes, and snippets.

@pedromtavares
Created April 19, 2010 13:20
Show Gist options
  • Save pedromtavares/371033 to your computer and use it in GitHub Desktop.
Save pedromtavares/371033 to your computer and use it in GitHub Desktop.
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