Class: ProgressiveRender::Rails::PathResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/progressive_render/rails/path_resolver.rb

Overview

Resolve set of request parameters to a full path to a template file

Defined Under Namespace

Classes: InvalidPathException, InvalidTemplateContextException, TemplateContext

Instance Method Summary collapse

Constructor Details

#initialize(template_context) ⇒ PathResolver

Returns a new instance of PathResolver.



35
36
37
# File 'lib/progressive_render/rails/path_resolver.rb', line 35

def initialize(template_context)
  @context = template_context
end

Instance Method Details

#path_for(view_name = nil) ⇒ Object



39
40
41
42
43
44
# File 'lib/progressive_render/rails/path_resolver.rb', line 39

def path_for(view_name = nil)
  raise InvalidTemplateContextException unless @context && @context.valid?
  raise InvalidPathException if (view_name.nil? || view_name.empty?) && view_action?

  "#{@context.controller.downcase}/#{path_suffix_for(view_name)}"
end