Module: GollyUtils::Callbacks::ModuleMethods
- Defined in:
- lib/golly-utils/callbacks.rb
Overview
Provides methods that can be run within definitions of modules that include GollyUtils::Callbacks.
Instance Method Summary collapse
-
#callbacks ⇒ Array<Symbol>
Returns a list of all callbacks available to this module.
-
#define_callbacks(*callbacks) ⇒ true
(also: #define_callback)
Create one or more callback points that will be added to classes that include the enclosing module.
Instance Method Details
#callbacks ⇒ Array<Symbol>
Returns a list of all callbacks available to this module. (i.e. defined, inherited, and included.)
119 120 121 122 123 124 125 |
# File 'lib/golly-utils/callbacks.rb', line 119 def callbacks c= __module_callback_names included_modules.each {|m| c.concat m.callbacks if m.respond_to? :callbacks } c.uniq.sort_by(&:to_s) end |
#define_callbacks(*callbacks) ⇒ true Also known as: define_callback
Create one or more callback points that will be added to classes that include the enclosing module.
109 110 111 112 113 |
# File 'lib/golly-utils/callbacks.rb', line 109 def define_callbacks(*callbacks) __module_callback_names.concat callbacks __module_callback_names.uniq! true end |