Module: Roda::RodaPlugins::PathRewriter::ClassMethods

Defined in:
lib/roda/plugins/path_rewriter.rb

Instance Method Summary collapse

Instance Method Details

#freezeObject

Freeze the path rewrite metadata.



49
50
51
52
53
# File 'lib/roda/plugins/path_rewriter.rb', line 49

def freeze
  opts[:remaining_path_rewrites].freeze
  opts[:path_info_rewrites].freeze
  super
end

#rewrite_path(was, is, opts = OPTS) ⇒ Object

Record a path rewrite from path was to path is. Options:

:path_info

Modify PATH_INFO, not just remaining path.



57
58
59
60
61
# File 'lib/roda/plugins/path_rewriter.rb', line 57

def rewrite_path(was, is, opts=OPTS)
  was = /\A#{Regexp.escape(was)}/ unless was.is_a?(Regexp)
  array = @opts[opts[:path_info] ? :path_info_rewrites : :remaining_path_rewrites]
  array << [was, is.dup.freeze].freeze
end