Sha256: a5ca0df5286f2ba2efc1215ae591ae6c29b99b6ddbdc4ca0899c172fbb7f2b00
Contents?: true
Size: 1.81 KB
Versions: 3
Compression:
Stored size: 1.81 KB
Contents
# -*- ruby -*- # frozen_string_literal: true require 'mongrel2' unless defined?( Mongrel2 ) require 'mongrel2/config' unless defined?( Mongrel2::Config ) # Mongrel2 Route configuration class class Mongrel2::Config::Route < Mongrel2::Config( :route ) extend Loggability log_to :mongrel2 ### As of Mongrel2/1.8.0: # CREATE TABLE route (id INTEGER PRIMARY KEY, # path TEXT, # reversed BOOLEAN DEFAULT 0, # host_id INTEGER, # target_id INTEGER, # target_type TEXT); ### Return the Route that corresponds to the given +request+. def self::for_request( request ) pattern = request.headers.pattern self.log.debug "Searching for the route for the path %p in %p" % [ pattern, self.all ] return self.filter( path: pattern ).first end # # :section: Associations # ## # The Mongrel2::Config::Host this route belongs to. many_to_one :host ### Fetch the route's target, which is either a Mongrel2::Config::Directory, ### Mongrel2::Config::Proxy, or Mongrel2::Config::Handler object. def target case self.target_type when 'dir' return Mongrel2::Config::Directory[ self.target_id ] when 'proxy' return Mongrel2::Config::Proxy[ self.target_id ] when 'handler' return Mongrel2::Config::Handler[ self.target_id ] else raise ArgumentError, "unknown target type %p" % [ self.target_type ] end end ### Set the target of the route to +object+, which should be one of the classes ### returned from #target. def target=( object ) case object when Mongrel2::Config::Directory self.target_type = 'dir' when Mongrel2::Config::Proxy self.target_type = 'proxy' when Mongrel2::Config::Handler self.target_type = 'handler' else raise ArgumentError, "unknown target type %p" % [ object.class ] end self.target_id = object.id end end # class Mongrel2::Config::Route
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mongrel2-0.55.0 | lib/mongrel2/config/route.rb |
mongrel2-0.54.0 | lib/mongrel2/config/route.rb |
mongrel2-0.53.0 | lib/mongrel2/config/route.rb |