registry is used to mix into a super class that has many or multiple implementations via subclasses.
A good example of this is a parser, you might have a parser for json and another for yml. Register your sub classes to handle certain labels or descriptions, then let the super class decide weather the message you send it can be handled or not.
A simple set of parsers:
Look for your the json parser
Or the Yaml parser. Notice it also uses its class name as an identifier
There is no parser for XML, this will raise a
Perhaps you'd like to call methods on the matching parser with a block? You can!
Parser.for(:json) do parse(feed) end
gem install registry --source http://gemcutter.org
Note on Patches/Pull Requests
- Fork the project.
- Make your feature addition or bug fix.
- Add tests for it. This is important so I don't break it in a future version unintentionally.
- Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
- Send me a pull request. Bonus points for topic branches.
Copyright (c) 2009 Ben Schwarz. See LICENSE for details.