perplexes / m2r

Mongrel2 Connection Adapter - Ruby Encrusted Steel-Reinforced Fist
MIT License
90 stars 11 forks source link

Change Connection constructor to take sockets #18

Closed paneq closed 12 years ago

paneq commented 12 years ago

The connection needs only request and response sockets as dependency for proper working. For the most simple case Connection working with one instance of mongrel2 can be created using Connection.for method instead of Connection.new :

Connection.for(sender_id, request_addr, response_addr, context)

Standard method using

Connection.new(request_socket, response_socket)

is used for more general usecase. For example if someone wants the handler to work with two mongrel2 instances the sockets can be created "by hand" and connected to both mongrels.

That way we have standard constructor for general usage and a method delegated for the most common case that takes identical arguments as initialize did before this refactoring.

paneq commented 12 years ago

It will also allow for easier testing with mocks.