View Source Bunch.Module (Bunch v1.6.1)
A bunch of functions for easier manipulation on modules.
Summary
Functions
Works like Kernel.apply/3
if module
exports fun_name/length(args)
,
otherwise returns default
.
Determines whether module implements a behaviour by checking a test function.
Ensures that module is loaded and checks whether it exports given function.
Returns instance of struct defined in given module, if the module defines struct.
Otherwise returns nil
.
Functions
Works like Kernel.apply/3
if module
exports fun_name/length(args)
,
otherwise returns default
.
Determines if function is exported using loaded_and_function_exported?/3
.
Determines whether module implements a behaviour by checking a test function.
Checked behaviour needs to define a callback with unique name and no arguments,
that should return true
. This functions ensures that the module is loaded and
checks if it exports implementation of the callback that returns true
. If
all these conditions are met, true
is returned. Otherwise returns false
.
@spec loaded_and_function_exported?(module(), atom(), non_neg_integer()) :: boolean()
Ensures that module is loaded and checks whether it exports given function.
Returns instance of struct defined in given module, if the module defines struct.
Otherwise returns nil
.
Raises if struct has any required fields.