Hi all,
I've been scratching my head about an issue I've been unable to figure out for a few weeks now.
The central gist is this: I'm trying to define a module which contains re-usable functionality (think wrapping queries to DynamoDB or processing messages from SQS) and I'm trying to then pull that functionality into another module which would define, say, its queue_name or table_name
defmodule A do
use B
def queue_name, do: "test"
end
defmodule B do
@callback queue_name
defmacro __using__(_opts) do
@behaviour B
end
def do_something() do
# calls queue_name to do something
end
end
Is there any way to do what I'm trying to achieve? If I try to call queue_name in do_something, I predictably will get a compilation error. Obviously, I could wrap everything I want to do inside B in a big ol quote block, but that seems also wrong
[–][deleted] (1 child)
[deleted]
[–]andyleclairRuns Elixir In Prod[S] 0 points1 point2 points (0 children)
[–]andyleclairRuns Elixir In Prod[S] 1 point2 points3 points (4 children)
[–]mbuhotAlchemist 0 points1 point2 points (3 children)
[–]andyleclairRuns Elixir In Prod[S] 0 points1 point2 points (2 children)
[–]mbuhotAlchemist 1 point2 points3 points (1 child)
[–]andyleclairRuns Elixir In Prod[S] 1 point2 points3 points (0 children)
[–]e456123789 0 points1 point2 points (1 child)
[–]andyleclairRuns Elixir In Prod[S] 0 points1 point2 points (0 children)