Method: Mongrel2::Config::Host::DSLMethods#handler
- Defined in:
- lib/mongrel2/config/host.rb
#handler(send_spec, send_ident, recv_spec = nil, recv_ident = '', options = {}) ⇒ Object
Create a new Mongrel2::Config::Handler object with the specified send_spec, send_ident, recv_spec, recv_ident, and options and return it.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/mongrel2/config/host.rb', line 82 def handler( send_spec, send_ident, recv_spec=nil, recv_ident='', ={} ) # Shift the opts hash over if the other optional args were omitted if recv_spec.is_a?( Hash ) = recv_spec recv_spec = nil elsif recv_ident.is_a?( Hash ) = recv_ident recv_ident = '' end # Default to one port below the request spec unless recv_spec port = send_spec[ /:(\d+)$/, 1 ] or "Can't guess default port for a send_spec without one (%p)" % [ send_spec ] recv_spec = URI( send_spec ) recv_spec.port = port.to_i - 1 end .merge!( :send_spec => send_spec.to_s, :send_ident => send_ident, :recv_spec => recv_spec.to_s, :recv_ident => recv_ident ) existing = Mongrel2::Config::Handler.filter( :send_ident => send_ident ) unless existing.select( :id ).empty? self.log.debug "Dropping existing %p handler." % [ send_ident ] existing.delete end self.log.debug "Creating handler with options: %p" % [ ] return Mongrel2::Config::Handler.create( ) end |