-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring the email preview setup (#41)
* Refactoring the email preview setup to make it a little less confusing. Also helps to prevent error prone setup with non-uri compliant keys. Ref #23 * oops. forgot to remove this require after deciding to ditch it
- Loading branch information
Showing
3 changed files
with
42 additions
and
36 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
# TODO: Move this in to Carbon directly | ||
abstract class Carbon::EmailPreviews | ||
alias EmailLookup = Hash(String, Carbon::Email) | ||
|
||
abstract def previews : EmailLookup | ||
abstract def previews : Array(Carbon::Email) | ||
|
||
def self.find(key : String) : Carbon::Email | ||
self.new.previews[key]? || raise "No Carbon::Email found with the key #{key}. Be sure to add it to your `previews` method" | ||
email = self.new.previews.find do |carbon| | ||
carbon.class.name == key | ||
end | ||
|
||
email || raise "No Carbon::Email found with the key #{key}. Be sure to add it to your `previews` method" | ||
end | ||
end |
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