Created
December 23, 2011 18:32
-
-
Save saturnflyer/1515021 to your computer and use it in GitHub Desktop.
allowing objects to specify exception types
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 Share | |
def call | |
list.each do |address| | |
begin | |
referral = new_referral(address) | |
referral.save | |
rescue referral.invalid_exception_type | |
@unsaved << referral | |
end | |
end | |
end | |
def new_referral(address) | |
Referral.new(address) | |
end | |
end | |
class Referral | |
class Invalid < StandardError; end | |
def invalid_exception_type | |
Referral::Invalid | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's interesting. I will ponder this.