Class: Wolverine::PathComponent
- Inherits:
-
Object
- Object
- Wolverine::PathComponent
- Defined in:
- lib/wolverine/path_component.rb
Overview
A PathComponent represents either the Wolverine.config.script_path
directory, or a subdirectory of it. Calling (nearly) any method on it will cause it to look in the filesystem at the location it refers to for a file or directory matching the method name. These results are cached.
Calling a method that maps to a directory will return a new PathComponent with a path
referring to that directory.
Calling a method that maps to a file (with ‘.lua’ automatically appended to the name) will load the file via Script and call it with the arugments passed, returning the result (#method_missing).
Defined Under Namespace
Classes: MissingTemplate
Instance Method Summary collapse
-
#initialize(path, options = {}) ⇒ PathComponent
constructor
A new instance of PathComponent.
-
#method_missing(sym, *args) ⇒ PathComponent, Object
A new, nested PathComponent if
sym
resolves to a directory, or an execution result if it resolves to a file.
Constructor Details
#initialize(path, options = {}) ⇒ PathComponent
Returns a new instance of PathComponent.
18 19 20 21 22 23 24 |
# File 'lib/wolverine/path_component.rb', line 18 def initialize path, = {} @path = path @options = @cache_to = [:cache_to] @redis = [:redis] || Wolverine.redis @config = [:config] || Wolverine.config end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ PathComponent, Object
Returns A new, nested Wolverine::PathComponent if sym
resolves to a directory, or an execution result if it resolves to a file.
31 32 33 34 |
# File 'lib/wolverine/path_component.rb', line 31 def method_missing sym, *args create_method sym, *args send sym, *args end |