Class: DiceBag::AvailableTemplates

Inherits:
Object
  • Object
show all
Defined in:
lib/dice_bag/available_templates.rb

Direct Known Subclasses

CommonTemplatesBag

Class Method Summary collapse

Class Method Details

.allObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/dice_bag/available_templates.rb', line 16

def all
  #all the classes than inherit from us in the ruby runtime
  available_templates = []

  template_checkers.each do |checker|
    checker.new.templates.each do |template|
      available_templates.push( template)
    end
  end
  available_templates
end

.inherited(base) ⇒ Object



12
13
14
# File 'lib/dice_bag/available_templates.rb', line 12

def inherited(base)
  template_checkers << base
end

.template_checkersObject



8
9
10
# File 'lib/dice_bag/available_templates.rb', line 8

def template_checkers
  @template_checkers ||= []
end

.template_filename_for(filename) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/dice_bag/available_templates.rb', line 28

def template_filename_for(filename)
  self.all.each do |template_filename|
    if template_filename.include? filename
      return template_filename
    end
  end
end