Sha256: ef6dbe09be3d367658880d4ae04c96af2b03096cb48e4669842f24f52dff271a
Contents?: true
Size: 859 Bytes
Versions: 62
Compression:
Stored size: 859 Bytes
Contents
# This is the base class for the registrars. # It defines the interface that other registrars inherit. # This is an abstract class. # The child classes inheriting this interface must define the 'value' method. module DispatchRider module Registrars class Base attr_reader :store def initialize @store = {} end def register(name, options = {}) store[name.to_sym] = value(name, options) self rescue NameError raise NotFound.new(name) end def value(name, options = {}) raise NotImplementedError end def unregister(name) store.delete(name.to_sym) self end def fetch(name) begin store.fetch(name.to_sym) rescue IndexError raise NotRegistered.new(name) end end end end end
Version data entries
62 entries across 62 versions & 1 rubygems