Hi Chris If you included some existing code (maybe your model files), I think people will have a easier time responding. That being said, I'll take a stab at it:
If I understand your requirements, 2 solutions jump to mind. Both of these are easily implemented in Rails. Single Table Inheritance Polymorphic Association Both are covered (Rails style) in the Rails Guide: http://guides.rubyonrails.org/association_basics.html This would enable you to have BigSource, LittleSource, and SpecialSource models to leverage. Not sure if that is useful to you in your application. Cheers Ben On Nov 16, 2011, at 11:37 AM, Chris Radcliff wrote: > I'm new to Ruby and Rails, but I'm diving in with both feet. Resources > around the web have been great so far, but I can't seem to find the > idiomatic way to write a plug-in style architecture. Specifically: > > Each Item in my model belongs to a Source identified by a shortname > (like bigsource). Rather than have a db-backed Source, I need to have > an arbitrary set of source types (bigsource, littlesource, > specialsource, etc), each of which are developed separately. Each > source type needs to do two things: > > 1. identify itself as the "answer" to a "question" in the form of a > URL. Newbcode examples: >>> Source.find_by_url("http://bigsource.com/foo").shortname > => 'bigsource' >>> Source.find_by_url("http://mrsmith.littlesource.com/").shortname > => 'littlesource' >>> Source.find_by_url("http://google.com/") > => nil > > 2. answer a predefined set of questions about the URL it claims to > know about, using whatever code it needs to get the answers. Newbcode > examples: >>> Source.find_by_url("http://bigsource.com/foo").account > => "1234567890" >>> Source.find_by_url("http://mrsmith.littlesource.com/").profile_name > => "John Smith" > > I have *my* way to do it, but what's the idiomatic Ruby way to define > these? Can you point me to any examples that work kinda like this? > > Thanks, > ~chris > > -- > SD Ruby mailing list > [email protected] > http://groups.google.com/group/sdruby -- SD Ruby mailing list [email protected] http://groups.google.com/group/sdruby
