Class: Rack::URLMap
Overview
Some overridings of Delegator
Instance Method Summary collapse
-
#_visit(path, block) ⇒ Object
Overrides Delegator._visit.
-
#find_rack_app(path = nil, &block) ⇒ Object
Overrides Delegator.find_rack_app.
Instance Method Details
#_visit(path, block) ⇒ Object
Overrides Delegator._visit
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/waw/ext/rack/urlmap.rb', line 39 def _visit(path, block) block.call(path, self) @mapping.each do |host, location, match, app| # seems required on some configurations where rack does not acts # as expected (3 arguments and not 4) app = match if app.nil? unless is_delegate?(app) Waw.logger.warn("We found a rack application which is not a delegator on #{path}: #{app.inspect}!") next end app._visit((location.to_s.empty? ? path : path.chomp('/') + location.to_s), block) end end |
#find_rack_app(path = nil, &block) ⇒ Object
Overrides Delegator.find_rack_app
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/waw/ext/rack/urlmap.rb', line 7 def find_rack_app(path = nil, &block) return self if (block && block.call(self)) the_app, the_rest = nil, nil if path.nil? @mapping.each do |host, location, match, app| if is_delegate?(app) found = app.find_rack_app(path, &block) return found if found end end return nil else @mapping.each do |host, location, match, app| next unless path =~ match && rest = $1 next unless rest.empty? || rest[0] == ?/ the_app, the_rest = app, rest break end if the_app # we've found one if the_rest.empty? or the_rest=='/' block ? the_app.find_rack_app(nil, &block) : the_app else the_app.find_rack_app(the_rest, &block) end else nil end end end |