Class: CanvasSync::JobBatches::RedisScript::TemplateContext
- Inherits:
 - 
      Object
      
        
- Object
 - CanvasSync::JobBatches::RedisScript::TemplateContext
 
 
- Defined in:
 - lib/canvas_sync/job_batches/redis_script.rb
 
Instance Method Summary collapse
- 
  
    
      #include_partial(relative_path)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
helper method to include a lua partial within another lua script.
 - 
  
    
      #initialize(script_path)  ⇒ TemplateContext 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of TemplateContext.
 - #template(pathname) ⇒ Object
 
Constructor Details
#initialize(script_path) ⇒ TemplateContext
Returns a new instance of TemplateContext.
      69 70 71  | 
    
      # File 'lib/canvas_sync/job_batches/redis_script.rb', line 69 def initialize(script_path) @script_path = script_path end  | 
  
Instance Method Details
#include_partial(relative_path) ⇒ Object
helper method to include a lua partial within another lua script
      82 83 84 85 86 87  | 
    
      # File 'lib/canvas_sync/job_batches/redis_script.rb', line 82 def include_partial(relative_path) unless @partial_templates.has_key? relative_path @partial_templates[relative_path] = nil template( Pathname.new("#{@script_path}/#{relative_path}") ) end end  | 
  
#template(pathname) ⇒ Object
      73 74 75 76  | 
    
      # File 'lib/canvas_sync/job_batches/redis_script.rb', line 73 def template(pathname) @partial_templates ||= {} ERB.new(File.read(pathname)).result binding end  |