class RoutingFilter::Filter
Attributes
next[RW]
options[RW]
previous[RW]
Public Class Methods
new(options = {})
click to toggle source
# File lib/routing_filter/filter.rb, line 5 def initialize(options = {}) @options = options end
Public Instance Methods
run(method, *args, &block)
click to toggle source
# File lib/routing_filter/filter.rb, line 9 def run(method, *args, &block) _next = self.next ? proc {|path, env| self.next.run(method, *args, &block) } : block RoutingFilter.active? ? send(method, *args, &_next) : _next.call(*args) end
run_reverse(method, *args, &block)
click to toggle source
# File lib/routing_filter/filter.rb, line 14 def run_reverse(method, *args, &block) _prev = previous ? lambda { previous.run_reverse(method, *args, &block) } : block RoutingFilter.active? ? send(method, *args, &_prev) : _prev.call(*args) end
Protected Instance Methods
append_segment(url, segment)
click to toggle source
# File lib/routing_filter/filter.rb, line 31 def append_segment(url, segment) url.sub(%r(/?($|\?))) { "/#{segment}#{$1}" } end
extract_segment!(pattern, path)
click to toggle source
# File lib/routing_filter/filter.rb, line 21 def extract_segment!(pattern, path) path.sub!(pattern) { $2 || '' } path.replace('/') if path.empty? $1 end
prepend_segment(url, segment)
click to toggle source
# File lib/routing_filter/filter.rb, line 27 def prepend_segment(url, segment) url.sub(%r(^(http.?://[^/]*)?(.*))) { "#{$1}/#{segment}#{$2 == '/' ? '' : $2}" } end