Monkey Patching Dependency Injector
monkey provides two core functions:
Here is an example where
monkey will be most likely used, in testing.
class User save: () -> # real functionality find: (id) -> # look up the user user = new User monkey.patch user, save: () -> true find: () -> new User ... run some tests ... # revert user back to normal monkey.unpatch user # do some other change to user monkey.patch user, save: () -> false find: () -> null ... etc ..