Class: Toys::ModuleLookup
- Inherits:
-
Object
- Object
- Toys::ModuleLookup
- Defined in:
- core-docs/toys/module_lookup.rb
Overview
Defined in the toys-core gem
A helper module that provides methods to do module lookups. This is used to obtain named helpers, middleware, and templates from the respective modules.
Class Method Summary collapse
-
.path_to_module(path) ⇒ Module
Given a require path, return the module expected to be defined.
-
.to_module_name(str) ⇒ Symbol
Convert the given string to a module name.
-
.to_path_name(str) ⇒ String
Convert the given string to a path element.
Instance Method Summary collapse
-
#add_path(path_base, module_base: nil, high_priority: false) ⇒ self
Add a lookup path for modules.
-
#initialize ⇒ ModuleLookup
constructor
Create an empty ModuleLookup.
-
#lookup(name) ⇒ Module
Obtain a named module.
Constructor Details
#initialize ⇒ ModuleLookup
Create an empty ModuleLookup
47 48 49 |
# File 'core-docs/toys/module_lookup.rb', line 47 def initialize # Source available in the toys-core gem end |
Class Method Details
.path_to_module(path) ⇒ Module
Given a require path, return the module expected to be defined.
39 40 41 |
# File 'core-docs/toys/module_lookup.rb', line 39 def path_to_module(path) # Source available in the toys-core gem end |
.to_module_name(str) ⇒ Symbol
Convert the given string to a module name. Specifically, converts
to UpperCamelCase
, and then to a symbol.
29 30 31 |
# File 'core-docs/toys/module_lookup.rb', line 29 def to_module_name(str) # Source available in the toys-core gem end |
.to_path_name(str) ⇒ String
Convert the given string to a path element. Specifically, converts
to lower_snake_case
.
18 19 20 |
# File 'core-docs/toys/module_lookup.rb', line 18 def to_path_name(str) # Source available in the toys-core gem end |
Instance Method Details
#add_path(path_base, module_base: nil, high_priority: false) ⇒ self
Add a lookup path for modules.
61 62 63 |
# File 'core-docs/toys/module_lookup.rb', line 61 def add_path(path_base, module_base: nil, high_priority: false) # Source available in the toys-core gem end |
#lookup(name) ⇒ Module
Obtain a named module. Returns nil
if the name is not present.
71 72 73 |
# File 'core-docs/toys/module_lookup.rb', line 71 def lookup(name) # Source available in the toys-core gem end |