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