Skip to content

Instantly share code, notes, and snippets.

@edofic
Created July 18, 2013 09:52
Show Gist options
  • Save edofic/6028143 to your computer and use it in GitHub Desktop.
Save edofic/6028143 to your computer and use it in GitHub Desktop.
slumber like urls in scala
import language.dynamics
class Path(path: String) extends Dynamic {
def selectDynamic(m: String) = new Path(s"$path$m/")
def applyDynamic(m: String)(args: Any*) = s"$m: $path with args $args"
override def toString = s"Path($path)"
}
val root = new Path("/")
//magic happens here
root.get() // get: / with args List()
root.foo.bar.post("baz") // post: /foo/bar/ with args WrappedArray(baz)
@edofic
Copy link
Author

edofic commented Jul 18, 2013

applyDynamic can use those parameters and do something useful instead

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