Jiken.Loaders.Mock (Jiken v0.0.1)
View SourceAll functionality related to overwriting code is handled in this module.
Jiken first checks if the mocked function exists. If it does, it stores the original module with a suffix to its namespace of .Original. It is stored in ETS.
Jiken also stores the mocked implementation in a different ETS table. Globally mocked functions and per-process mocks are stored separately.
Then, Jiken goes through all of the function definitions of the module until it finds the mocked function, it updates its implementation to mocked version of the function from ETS, depending on if it is mocked globally or per process.
If it cannot find a mock at this step, it falls back to the original implementation.