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)
- 
  
    
      - (PathComponent) initialize(path) 
    
    
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of PathComponent. 
- 
  
    
      - (PathComponent, Object) method_missing(sym, *args) 
    
    
  
  
  
  
  
  
  
  
    A new, nested PathComponent if sym resolves to a directory, or an execution result if it resolves to a file. 
Constructor Details
- (PathComponent) initialize(path)
A new instance of PathComponent
| 17 18 19 | # File 'lib/wolverine/path_component.rb', line 17 def initialize path @path = path end | 
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (PathComponent, Object) method_missing(sym, *args)
A new, nested Wolverine::PathComponent if sym resolves to a directory, or an execution result if it resolves to a file.
| 26 27 28 29 | # File 'lib/wolverine/path_component.rb', line 26 def method_missing sym, *args create_method sym, *args send sym, *args end |