Sha256: 38aa143aaacfe10ed33a0bbe1f4438e12e6922dcb1f91902aaa6166764f0954c

Contents?: true

Size: 504 Bytes

Versions: 29

Compression:

Stored size: 504 Bytes

Contents

module Shoulda
  module Matchers
    module Integrations
      # @private
      class Registry
        def register(klass, name)
          registry[name] = klass
        end

        def find!(name)
          find_class!(name).new
        end

        private

        def registry
          @_registry ||= {}
        end

        def find_class!(name)
          registry.fetch(name) do
            raise ArgumentError, "'#{name}' is not registered"
          end
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
shoulda-matchers-6.4.0 lib/shoulda/matchers/integrations/registry.rb
shoulda-matchers-6.3.1 lib/shoulda/matchers/integrations/registry.rb
shoulda-matchers-6.3.0 lib/shoulda/matchers/integrations/registry.rb
shoulda-matchers-6.2.0 lib/shoulda/matchers/integrations/registry.rb
shoulda-matchers-6.1.0 lib/shoulda/matchers/integrations/registry.rb
shoulda-matchers-6.0.0 lib/shoulda/matchers/integrations/registry.rb
shoulda-matchers-5.3.0 lib/shoulda/matchers/integrations/registry.rb
shoulda-matchers-5.2.0 lib/shoulda/matchers/integrations/registry.rb
shoulda-matchers-5.1.0 lib/shoulda/matchers/integrations/registry.rb
shoulda-matchers-5.0.0 lib/shoulda/matchers/integrations/registry.rb
shoulda-matchers-5.0.0.rc1 lib/shoulda/matchers/integrations/registry.rb
shoulda-matchers-4.5.1 lib/shoulda/matchers/integrations/registry.rb
shoulda-matchers-4.5.0 lib/shoulda/matchers/integrations/registry.rb
shoulda-matchers-4.4.1 lib/shoulda/matchers/integrations/registry.rb
shoulda-matchers-4.4.0 lib/shoulda/matchers/integrations/registry.rb
shoulda-matchers-4.3.0 lib/shoulda/matchers/integrations/registry.rb
shoulda-matchers-4.2.0 lib/shoulda/matchers/integrations/registry.rb
shoulda-matchers-4.1.2 lib/shoulda/matchers/integrations/registry.rb
shoulda-matchers-4.1.1 lib/shoulda/matchers/integrations/registry.rb
shoulda-matchers-4.1.0 lib/shoulda/matchers/integrations/registry.rb