module HTTPX::Registry::ClassMethods

  1. lib/httpx/registry.rb

Class Methods

Methods

Public Instance

  1. inherited
  2. register
  3. registry

Public Instance methods

inherited (klass)
[show source]
   # File lib/httpx/registry.rb
49 def inherited(klass)
50   super
51   klass.instance_variable_set(:@registry, @registry.dup)
52 end
register (tag, handler)

@param [Object] tag the identifier for the handler in the registry @return [Symbol, String, Object] the handler (if Symbol or String, it is

assumed to be an autoloaded module, to be loaded later)
[show source]
   # File lib/httpx/registry.rb
77 def register(tag, handler)
78   registry[tag] = handler
79 end
registry (tag = nil)

@param [Object] tag the handler identifier in the registry @return [Symbol, String, Object] the corresponding handler (if Symbol or String,

will assume it referes to an autoloaded module, and will load-and-return it).
[show source]
   # File lib/httpx/registry.rb
58 def registry(tag = nil)
59   @registry ||= {}
60   return @registry if tag.nil?
61 
62   handler = @registry.fetch(tag)
63   raise(Error, "#{tag} is not registered in #{self}") unless handler
64 
65   case handler
66   when Symbol, String
67     const_get(handler)
68   else
69     handler
70   end
71 end