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

Version Path
dispatch-rider-1.3.6 lib/dispatch-rider/registrars/base.rb
dispatch-rider-1.3.5 lib/dispatch-rider/registrars/base.rb
dispatch-rider-1.3.4 lib/dispatch-rider/registrars/base.rb
dispatch-rider-1.3.3 lib/dispatch-rider/registrars/base.rb
dispatch-rider-1.3.2 lib/dispatch-rider/registrars/base.rb
dispatch-rider-1.3.1 lib/dispatch-rider/registrars/base.rb
dispatch-rider-1.3.0 lib/dispatch-rider/registrars/base.rb
dispatch-rider-1.2.11 lib/dispatch-rider/registrars/base.rb
dispatch-rider-1.2.10 lib/dispatch-rider/registrars/base.rb
dispatch-rider-1.2.9 lib/dispatch-rider/registrars/base.rb
dispatch-rider-1.2.8 lib/dispatch-rider/registrars/base.rb
dispatch-rider-1.2.7 lib/dispatch-rider/registrars/base.rb
dispatch-rider-1.2.6 lib/dispatch-rider/registrars/base.rb
dispatch-rider-1.2.5 lib/dispatch-rider/registrars/base.rb
dispatch-rider-1.2.4 lib/dispatch-rider/registrars/base.rb
dispatch-rider-1.2.3 lib/dispatch-rider/registrars/base.rb
dispatch-rider-1.2.2 lib/dispatch-rider/registrars/base.rb
dispatch-rider-1.2.1 lib/dispatch-rider/registrars/base.rb
dispatch-rider-1.2.0 lib/dispatch-rider/registrars/base.rb
dispatch-rider-1.1.7 lib/dispatch-rider/registrars/base.rb