Class: DevelopWithPassion::Expander::TemplateProcessors

Inherits:
Object
  • Object
show all
Defined in:
lib/developwithpassion_expander/template_processors.rb

Instance Method Summary collapse

Constructor Details

#initialize(processors = {}) ⇒ TemplateProcessors

Returns a new instance of TemplateProcessors.



4
5
6
# File 'lib/developwithpassion_expander/template_processors.rb', line 4

def initialize(processors = {})
  @processors = processors
end

Instance Method Details

#get_processor_for(file_name) ⇒ Object



8
9
10
11
12
# File 'lib/developwithpassion_expander/template_processors.rb', line 8

def get_processor_for(file_name)
  template_type = File.extname(file_name).gsub(/\./,'').to_sym
  raise "There is no processor for #{file_name}" unless processor_exists_for(template_type)
  return @processors[template_type]
end

#processor_exists_for(template_type) ⇒ Object



19
20
21
# File 'lib/developwithpassion_expander/template_processors.rb', line 19

def processor_exists_for(template_type)
  return @processors.has_key?(template_type.to_sym)
end

#register_processor(template_type, processor) ⇒ Object



14
15
16
17
# File 'lib/developwithpassion_expander/template_processors.rb', line 14

def register_processor(template_type,processor)
  raise "The processor for the template already exists" if processor_exists_for(template_type)
  @processors[template_type.to_sym] = processor
end