Class: Module
- Inherits:
-
Object
- Object
- Module
- Defined in:
- lib/module_ext.rb
Overview
TDD helpers for modules.
Defined Under Namespace
Modules: Reloader
Class Method Summary collapse
-
.by_name(name) ⇒ Object
load a module by name.
Instance Method Summary collapse
-
#etest ⇒ Object
reloads the module, and runs the module’s etests.
-
#instances ⇒ Object
returns all instances of a module.
-
#reload ⇒ Object
tries to reload the source file for this module.
Class Method Details
Instance Method Details
#etest ⇒ Object
reloads the module, and runs the module’s etests.
15 16 17 18 |
# File 'lib/module_ext.rb', line 15 def etest reload if respond_to?(:reload) ::Etest.run self.const_get("Etest") end |
#instances ⇒ Object
returns all instances of a module
22 23 24 25 26 |
# File 'lib/module_ext.rb', line 22 def instances #:nodoc: r = [] ObjectSpace.each_object(self) { |mod| r << mod } r end |
#reload ⇒ Object
tries to reload the source file for this module. THIS IS A DEVELOPMENT helper, don’t try to use it in production mode!
Limitations:
To reload a module with a name of “X::Y” we try to load (in that order) “x/y.rb”, “x.rb”
48 49 50 51 52 53 |
# File 'lib/module_ext.rb', line 48 def reload Module::Reloader.reload_file("#{to_s.underscore}.rb") || begin dlog("Cannot reload module #{self}") false end end |