Adds a general-purpose registry API to a class. It is designed to be a configuration-level API, i.e. the registry is global to the class and should be set on **boot time**.
It is used internally to associate tags with handlers.
One is strongly advised to register handlers when creating the class.
There is an instance-level method to retrieve from the registry based on the tag:
class Server include HTTPX::Registry register "tcp", TCPHandler register "ssl", SSLHandlers ... def handle(uri) scheme = uri.scheme handler = registry(scheme) #=> TCPHandler handler.handle end end
Public Class methods
# File lib/httpx/registry.rb 36 def self.extended(klass) 37 super 38 klass.extend(ClassMethods) 39 end
# File lib/httpx/registry.rb 41 def self.included(klass) 42 super 43 klass.extend(ClassMethods) 44 klass.__send__(:include, InstanceMethods) 45 end