Module.get_attribute

You're seeing just the function get_attribute, go back to Module module for more information.
Link to this function

get_attribute(module, key, default \\ nil)

View Source

Specs

get_attribute(module(), atom(), term()) :: term()

Gets the given attribute from a module.

If the attribute was marked with accumulate with Module.register_attribute/3, a list is always returned. nil is returned if the attribute has not been marked with accumulate and has not been set to any value.

The @ macro compiles to a call to this function. For example, the following code:

@foo

Expands to something akin to:

Module.get_attribute(__MODULE__, :foo)

This function can only be used on modules that have not yet been compiled. Use the Module.__info__/1 callback to get all persisted attributes, or Code.fetch_docs/1 to retrieve all documentation related attributes in compiled modules.

Examples

defmodule Foo do
  Module.put_attribute(__MODULE__, :value, 1)
  Module.get_attribute(__MODULE__, :value) #=> 1

  Module.get_attribute(__MODULE__, :value, :default) #=> 1
  Module.get_attribute(__MODULE__, :not_found, :default) #=> :default

  Module.register_attribute(__MODULE__, :value, accumulate: true)
  Module.put_attribute(__MODULE__, :value, 1)
  Module.get_attribute(__MODULE__, :value) #=> [1]
end