Class: Grape::Router::NormalizePathCache

Inherits:
Util::Cache show all
Defined in:
lib/grape/router.rb

Instance Attribute Summary

Attributes inherited from Util::Cache

#cache

Instance Method Summary collapse

Constructor Details

#initializeNormalizePathCache

Returns a new instance of NormalizePathCache.



21
22
23
24
25
26
27
28
29
# File 'lib/grape/router.rb', line 21

def initialize
  @cache = Hash.new do |h, path|
    normalized_path = +"/#{path}"
    normalized_path.squeeze!('/')
    normalized_path.sub!(%r{/+\Z}, '')
    normalized_path = '/' if normalized_path.empty?
    h[path] = -normalized_path
  end
end