Created
October 11, 2011 04:55
-
-
Save rafer/1277328 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
class Product | |
def list_price=(price) | |
write_price(:list_price, price) | |
end | |
def sales_price=(price) | |
write_price(:sales_price, price) | |
end | |
private | |
def write_price(attribute, raw) | |
sanitizied = raw.to_s.gsub(/[^\d\.]/, '') | |
write_attribute(attribute, sanitizied) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment