Public Instance methods
freeze()
Freeze the path rewrite metadata.
[show source]
# File lib/roda/plugins/path_rewriter.rb 60 def freeze 61 remaining_path_rewrites.freeze 62 path_info_rewrites.freeze 63 super 64 end
rewrite_path(was, is = nil, opts=OPTS, &block)
Record a path rewrite from path was to path is. Options:
| :path_info |
Modify PATH_INFO, not just remaining path. |
[show source]
# File lib/roda/plugins/path_rewriter.rb 68 def rewrite_path(was, is = nil, opts=OPTS, &block) 69 if is.is_a? Hash 70 raise RodaError, "cannot provide two hashes to rewrite_path" unless opts.empty? 71 opts = is 72 is = nil 73 end 74 75 if block 76 raise RodaError, "cannot provide both block and string replacement to rewrite_path" if is 77 is = block 78 end 79 80 was = /\A#{Regexp.escape(was)}/ unless was.is_a?(Regexp) 81 array = opts[:path_info] ? path_info_rewrites : remaining_path_rewrites 82 array << [was, is.dup.freeze].freeze 83 end