Created
July 18, 2013 09:52
-
-
Save edofic/6028143 to your computer and use it in GitHub Desktop.
slumber like urls in scala
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
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
applyDynamic can use those parameters and do something useful instead