From: Johnny Morrice Date: 2011-04-05T22:43:14+09:00 Subject: Re: Seeking advice On Tue, 5 Apr 2011 22:22:17 +0900 Alex Rothbard wrote: > What is the best way to allow the user of the library to specify a > transport at runtime? Use factory pattern The user should call something like MyProject::Transport::ThriftFactory.build Then they don't need to find the transport themselves. But it should be obvious what ThriftFactory returns. The following might be how you would do it, up to you really :) # I don't know what this is about, so I'm calling your class Foo here class Foo # My Foo transports all the data to the yard def initialize(transport) @t = transport @grid = @t::Grid.new end end # Factory to build the Foo which uses the Thrift Transporter class ThriftFactory # Users can make Foos that transport with Thrift without having to # find the Thrift themselves def build Foo.new MyProject::Transport::Thrift end end