Created
September 2, 2009 19:07
-
-
Save jzellman/179905 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Company | |
def zipcode | |
Zipcode.parse(get_attribute(:zipcode), self.country) | |
end | |
end | |
# example zipcode interface | |
class Zipcode | |
def self.parse(zipcode, country) | |
Object.const_get("Zipcode::#{country.upcase}").new(zipcode) | |
end | |
# the local part of zipcode that is typically included in things | |
# subclass impl | |
def local | |
end | |
# if supported, additional 4 digits | |
def extension | |
end | |
end | |
some_mid = params[:mid] | |
zipcode = params[:zipcode] | |
Company.find_by_mid(some_mid).select{|c| c.zipcode.local.eql?(zipcode) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment