module Riffer::Registrable

Registry of a class’s direct subclasses, keyed by identifier. Extend it onto a base class to look up subclasses in constant time via find and all. Subclasses join implicitly by inheriting; register adds one explicitly, for ephemeral classes a test suite builds and tears down. Registration is not synchronized — register during boot or from a single-threaded test, before concurrent lookups begin.

class Riffer::Tool
  extend Riffer::Registrable
end

Riffer::Tool.find("weather_tool") # => WeatherTool

@rbs module-self Class