Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #2338
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!talisker.lacave.net!lacave.net!not-for-mail |
|---|---|
| From | Alex Rothbard <alex323@gmail.com> |
| Newsgroups | comp.lang.ruby |
| Subject | Seeking advice |
| Date | Tue, 5 Apr 2011 08:22:17 -0500 |
| Organization | Service de news de lacave.net |
| Lines | 28 |
| Message-ID | <a5c155d833135cc1cccec3cf894380c8@ruby-forum.com> (permalink) |
| NNTP-Posting-Host | bristol.highgroove.com |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | talisker.lacave.net 1302009771 32653 65.111.164.187 (5 Apr 2011 13:22:51 GMT) |
| X-Complaints-To | abuse@lacave.net |
| NNTP-Posting-Date | Tue, 5 Apr 2011 13:22:51 +0000 (UTC) |
| X-Received-From | This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway |
| X-Mail-Count | 380997 |
| X-Ml-Name | ruby-talk |
| X-Rubymirror | Yes |
| X-Ruby-Talk | <a5c155d833135cc1cccec3cf894380c8@ruby-forum.com> |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.ruby:2338 |
Show key headers only | View raw
Hi. I am writing a library that will have the ability to access a server by many different "transports" (JSON over HTTP, Thrift, etc). Depending on which transport the user chooses, different files and classes will need to be loaded. A complete implementation of a transport requires that three classes (such as the 'Grid' class below) be implemented from their respective base class. Additionally, if the user wants to use JSON over HTTP, they shouldn't need to depend on the thrift gem and vice versa. These transport classes are used by other classes within the library, and should never be used directly by the user. What is the best way to allow the user of the library to specify a transport at runtime? Could I wrap all my implemented transport classes in a module and do something like this?: def initialize(transport) @t = transport @grid = @t::Grid.new end where "transport" could be "MyProject::Transport::Thrift". Is this a good idea? Is there a better way? -- Posted via http://www.ruby-forum.com/.
Back to comp.lang.ruby | Previous | Next — Next in thread | Find similar | Unroll thread
Seeking advice Alex Rothbard <alex323@gmail.com> - 2011-04-05 08:22 -0500
Re: Seeking advice Robert Klemme <shortcutter@googlemail.com> - 2011-04-05 08:39 -0500
Re: Seeking advice Johnny Morrice <spoon@killersmurf.com> - 2011-04-05 09:44 -0500
Re: Seeking advice Robert Klemme <shortcutter@googlemail.com> - 2011-04-05 10:23 -0500
Re: Seeking advice Johnny Morrice <spoon@killersmurf.com> - 2011-04-05 08:43 -0500
Re: Seeking advice Alex Rothbard <alex323@gmail.com> - 2011-04-05 13:30 -0500
Re: Seeking advice Jesús Gabriel y Galán <jgabrielygalan@gmail.com> - 2011-04-06 01:53 -0500
Re: Seeking advice Robert Klemme <shortcutter@googlemail.com> - 2011-04-06 04:30 -0500
csiph-web