Current section
Files
Jump to
Current section
Files
lib/jacob/concerns/required_attributes.ex
defmodule Jacob.Concerns.RequiredAttributes do
alias Jacob.RequiredAttributeMissingError
@moduledoc false
@doc """
Check that the given module has all the required attributes.
"""
def check(command_module, required_attributes) do
Enum.each(required_attributes, &check_required_attribute(command_module, &1))
end
defp check_required_attribute(module, attribute) do
unless Module.get_attribute(module, attribute) do
raise RequiredAttributeMissingError, attribute: attribute, module: module
end
end
end