Class: Captify::TemplateRegistrar
- Inherits:
-
Object
- Object
- Captify::TemplateRegistrar
- Defined in:
- lib/captify/template_registrar.rb
Constant Summary collapse
- @@instance =
TemplateRegistrar.new
Class Method Summary collapse
Instance Method Summary collapse
- #find(template_name) ⇒ Object
-
#initialize(template_builder = Captify::Template) ⇒ TemplateRegistrar
constructor
A new instance of TemplateRegistrar.
- #register(template) ⇒ Object
- #register_templates_in_dir(root_dir) ⇒ Object
- #template_count ⇒ Object
Constructor Details
#initialize(template_builder = Captify::Template) ⇒ TemplateRegistrar
Returns a new instance of TemplateRegistrar.
6 7 8 9 |
# File 'lib/captify/template_registrar.rb', line 6 def initialize(template_builder=Captify::Template) @template_builder = template_builder @templates = {} end |
Class Method Details
.instance ⇒ Object
13 14 15 |
# File 'lib/captify/template_registrar.rb', line 13 def self.instance @@instance end |
Instance Method Details
#find(template_name) ⇒ Object
33 34 35 |
# File 'lib/captify/template_registrar.rb', line 33 def find(template_name) @templates[template_name] end |
#register(template) ⇒ Object
29 30 31 |
# File 'lib/captify/template_registrar.rb', line 29 def register(template) @templates[template.name] = template unless @templates.key? template.name end |
#register_templates_in_dir(root_dir) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/captify/template_registrar.rb', line 17 def register_templates_in_dir(root_dir) template_dirs(root_dir).each do |dir| if template = @template_builder.load_from_path(dir) register template end end end |
#template_count ⇒ Object
25 26 27 |
# File 'lib/captify/template_registrar.rb', line 25 def template_count @templates.count end |