Module: Shaf::SymbolicRoutes

Defined in:
lib/shaf/extensions/symbolic_routes.rb

Defined Under Namespace

Classes: UriHelperNotRegisterdError

Instance Method Summary collapse

Instance Method Details

#rewrite_path(path, method) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/shaf/extensions/symbolic_routes.rb', line 12

def rewrite_path(path, method)
  return path unless path.is_a? Symbol

  ["#{path}_template", "#{path}_path_template"].each do |method|
    return send(method) if respond_to? method
  end

  raise UriHelperNotRegisterdError, <<~RUBY
    Undefined method '#{method}'. Did you forget to register a uri helper for #{path}?
  RUBY
end