Permalink
Browse files

Merge pull request #1 from ticking/master

Mock and DependencyInjection helper.
  • Loading branch information...
2 parents 151f67a + 182745b commit 10bfd99c6e2eebfd8afa5e641fbac77b48adc498 @jeremytregunna committed Nov 2, 2011
Showing with 35 additions and 0 deletions.
  1. +35 −0 lib/Mock.io
View
@@ -0,0 +1,35 @@
+InjectionLayer := Object clone do(
+ on := method(target,
+ new := self clone
+ new setSlot("injectionLayerBit")
+ new prependProto(target proto)
+ target setProto(new)
+ new
+ )
+
+ remove := method(
+ self become(self proto)
+ )
+ )
+
+Injectable := Object clone do(
+ injectInto := method(target,
+ target proto hasLocalSlot("injectionLayerBit") ifFalse(
+ InjectionLayer on(target)
+ )
+ target proto setSlot(self type, self)
+ self
+ )
+)
+
+Mock := Injectable clone do(
+ mocking := method(target,
+ new := self clone
+ target isKindOf(Sequence) ifTrue(
+ new type := target
+ ) ifFalse(
+ new prependProto(target)
+ )
+ new
+ )
+)

0 comments on commit 10bfd99

Please sign in to comment.