Permalink
Browse files

Added deep inspection methods to describe map.

  • Loading branch information...
1 parent 74219cf commit c54f1f83cd595e28c0d4b323573571c12c40f4a7 @dickwall committed Feb 2, 2012
Showing with 15 additions and 0 deletions.
  1. +15 −0 src/main/scala/org/scala_tools/subcut/inject/BindingModule.scala
@@ -333,13 +333,28 @@ trait MutableBindingModule extends BindingModule { outer =>
println(mapString.mkString("\n"))
}
+ def showDeepBindings() {
+ println(deepMapString.mkString("\n"))
+ }
+
/**
* A convenient way to obtain a string representation of the current bindings in this module.
*/
def mapString = {
for ((k, v) <- bindings) yield { k.toString + " -> " + v.toString }
}
+ def deepMapString = {
+ def getDeep(x: Any): String = x match {
+ case ip: ClassInstanceProvider[_] => "Class: " + ip.newInstance().toString
+ case lip: LazyInstanceProvider[_] => "Lazy: " + lip.instance.toString
+ case nip: NewInstanceProvider[_] => "New: " + nip.instance.toString
+ case i => "Just: " + i.toString
+ }
+
+ for ((k, v) <- bindings) yield { k.toString + " -> " + getDeep(v) }
+ }
+
/**
* Temporarily push the bindings (as though on a stack) and let the current bindings be overridden for
* the scope of a provided by-name function. The binding changes will be popped after execution of the

0 comments on commit c54f1f8

Please sign in to comment.