In working with the ExUnit code, there are at least two places where I think being able to introspect on module attributes would be useful.
One is
here. In this code it would be useful to know if a module attribute has been set already. This code checks to see if it has a value. However, if a user set the value to `nil`, this code wouldn't be able to tell.
So, the proposal is an API something like this:
defmodule X do
Module.register_attribute(__MODULE__, :foo, accumulate: true)
@bar true
Module.attribute_registered?(__MODULE__, :foo) #=> true
Module.attribute_registered?(__MODULE__, :foo, accumulate: true) #=> true
Module.attribute_registered?(__MODULE__, :foo, persist: true) #=> false
Module.attribute_registered?(__MODULE__, :bar) #=> true
Module.attribute_registered?(__MODULE__, :bar, accumulate: true) #=> false
Module.attribute_registered?(__MODULE__, :baz) #=> false
end
The third argument would be a subset match of the options.
Thoughts?