sarat1669
Module.module_info doesn't include all behaviours
I have a module which defines a behavior
defmodule Light.Trigger do
@callback initialize(%{}) :: {:ok, any()}
defmacro __using__(_) do
quote do
use GenServer
@behaviour Light.Trigger
...
end
end
And I am using it like
defmodule Light.Test do
use Light.Trigger
@impl true
def initialize(state) do
{:ok, state}
end
@impl true
def handle_info(:test, state) do
...
{:noreply, state}
end
end
This happens
iex> Light.Test.module_info[:attributes][:behaviour]
[GenServer]
But it should be
iex> Light.Test.module_info[:attributes][:behaviour]
[GenServer, Trigger]
right?
Most Liked
John-Goff
You can use Keyword — Elixir v1.20.2 to get the list that you want.
Keyword.get_values(Light.Test.module_info[:attributes], :behaviour)
6
hauleth
1.Use more idiomatic mod.module_info(:attributes).
2. It will mention only behaviours set via module attribute (you do not need to set that to implement behaviour). So there is no “100% correct” solution to list all implemented behaviours.
2
sarat1669
On further inspection:
iex> Light.Test.module_info[:attributes]
[
vsn: [325461190013957173593492030108196297138],
behaviour: [GenServer],
behaviour: [Light.Test]
]
1
Last Post!
bit4bit
see model_info i think it’s work as expected:
Returns a list of {AttributeName,ValueList} tuples,
where AttributeName is the name of an attribute, and ValueList is a list of values.
Notice that a given attribute can occur more than once in the list with different values if the attribute occurs more than once in the module.
0
Popular in Discussions
If a newbie asked you about Phoenix Contexts, how would you explain the basics to them?
Feel free to be as concise or in-depth as you li...
New
Another point that Dave drives home in his course is that applications really are components, and you should treat them as such. Not as “...
New
This is a post to discuss the new Phoenix LiveView functionality.
From Chris’s talk, it appears that they generate all HTML on the serve...
New
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help.
Where are they similar?
Where do they differ the m...
New
Hey guys!
I want to create a toy project that shows a chart of temperature over time and updates every 5 seconds. I feel LiveView is per...
New
Please, let me know if this kind of discussion already took place in another topic
.
Hi all, how do you consider if is better to build ...
New
Can you believe the first professionally published Elixir book was published just 8 years ago? Since then I think we’ve seen more books f...
New
Other popular topics
Update:
How to use the Blogs & Podcasts section
You can post links to your blog posts or podcasts either in one of the Official Blog...
New
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
New
If I have a post route which an argument:
post /my_post_route/:my_param1, MyController.my_post_handler
How would get the post params ...
New
Credo is smart enough to check for (something like) this:
assert length(the_list) == 0
with this response:
Checking if an enum is empt...
New
Hello everyone,
Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service.
Currently when I de...
New
Chat & Discussions>Discussions
Latest on Elixir Forum
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









