yes, there is, but it’s highly recommended to not do it. Your user (intended or not) can cause a memory leak by pushing as many of these as they want. Do you still want to know how to do it?
what about users you don’t intend to be on your system? Honestly, there’s probably a better way to do what you’re trying to do. What are you trying to do?
The code module has some things that might get you where you want to go. It’s a very very bad idea: Do try to find a better way to do what you’re trying to do. But since you want it here is an example:
iex(1)> Code.compile_string("""
...(1)> defmodule M do
...(1)> def f(x), do: x + 1
...(1)> end
...(1)> """)
<snip>
iex(2)> M.f(2)
3
iex(1)> defmodule Q do
...(1)> def f(code) do
...(1)> Code.compile_string(code)
...(1)> end
...(1)> end
iex(2)> Q.f("""
...(2)> defmodule M do
...(2)> def f(x), do: x + 1
...(2)> end
...(2)> """)
iex(3)> M.f(2)
3
Like if my employees pushed this code they might be fired. On the spot. Okay, if they were junior, i’d give them a warning. Second time, fired. On the spot.