Skip to content

Instantly share code, notes, and snippets.

@wfaler
Created January 18, 2011 00:39
Show Gist options
  • Save wfaler/783798 to your computer and use it in GitHub Desktop.
Save wfaler/783798 to your computer and use it in GitHub Desktop.
WidgetTransformer.scala
/**
* Transforms from single request parameters to an object, for instance in this case from a Widget ID
* to an Actual Widget, or returns None if a transformation cannot be done.<br/>
* Must be registered with the TransformerRegistry, as done in the bootstrap above.
*/
class WidgetTransformer extends StringValueTransformer[Widget]{
def toValue(from: String): Option[Widget] = Widgets.find(Integer.parseInt(from))
}
@Synesso
Copy link

Synesso commented Jan 26, 2011

if(widget == None)
  return None
else
  return widget

can be replaced with

return widget

Also, do you really mean to use the return keyword? Perhaps your intention is simply:

def toValue(from: String): Option[Widget] = Widgets.find(Integer.parseInt(from))

@wfaler
Copy link
Author

wfaler commented Jan 26, 2011

Good catch, I have no idea why it's been done that way. Brain meltdown. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment