Class: ActionPage::TemplateHandler
- Inherits:
-
Object
- Object
- ActionPage::TemplateHandler
- Defined in:
- lib/action_page/template_handler.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
- #handler_for_template ⇒ Object
-
#initialize(template, source) ⇒ TemplateHandler
constructor
A new instance of TemplateHandler.
- #last_line ⇒ Object
- #path_without_yaml ⇒ Object
- #source_without_yaml ⇒ Object
Constructor Details
#initialize(template, source) ⇒ TemplateHandler
Returns a new instance of TemplateHandler.
7 8 9 10 |
# File 'lib/action_page/template_handler.rb', line 7 def initialize(template, source) @template = template @source = source end |
Class Method Details
.call(template, source) ⇒ Object
3 4 5 |
# File 'lib/action_page/template_handler.rb', line 3 def self.call(template, source) new(template, source).call end |
Instance Method Details
#call ⇒ Object
12 13 14 |
# File 'lib/action_page/template_handler.rb', line 12 def call handler_for_template.call(@template, source_without_yaml) end |
#handler_for_template ⇒ Object
16 17 18 19 20 |
# File 'lib/action_page/template_handler.rb', line 16 def handler_for_template ApplicationController.new.view_paths.paths.first .extract_handler_and_format_and_variant(path_without_yaml) .first end |
#last_line ⇒ Object
30 31 32 |
# File 'lib/action_page/template_handler.rb', line 30 def last_line YAML.parse(@source).root.end_line end |
#path_without_yaml ⇒ Object
26 27 28 |
# File 'lib/action_page/template_handler.rb', line 26 def path_without_yaml @template.short_identifier.sub(/.ya?ml\z/, '') end |
#source_without_yaml ⇒ Object
22 23 24 |
# File 'lib/action_page/template_handler.rb', line 22 def source_without_yaml @source.lines[last_line+1...].join end |