Skip to content

Instantly share code, notes, and snippets.

@johanandren
Created September 13, 2013 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johanandren/6547569 to your computer and use it in GitHub Desktop.
Save johanandren/6547569 to your computer and use it in GitHub Desktop.
Different handling for diferent kinds of images
trait ImageResource {
def publicUrl: String
}
case class URLImage(source: URL) extends ImageResource {
def publicUrl = source.url
}
case class CDNImage(bucketName: String, key: String, cdnBaseUrl: String) extends ImageResource {
lazy val cdnUrl = URL(cdnBaseUrl) :+ key
def publicUrl = cdnUrl.url
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment