-
-
Save croaky/5185403 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 Customer | |
def initialize(attrs = {}) | |
@id = attrs[:id] | |
@country = attrs[:country] | |
end | |
def tax_code | |
TaxCodes[@country].call(@id) | |
rescue | |
raise "Tax codes for #{@country} not supported" | |
end | |
end | |
TaxCodes = { | |
'Brazil' => lambda { |id| "#{id}-BR" }, | |
'USA' => lambda { |id| "US-#{id}" } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment