Sha256: dbbefd4930b8e48bea24103936e35f6f90cc3776f90108485bdcb400bd9c349a

Contents?: true

Size: 547 Bytes

Versions: 6

Compression:

Stored size: 547 Bytes

Contents

module Adapter
  module Asserts
    RequiredMethods = [:read, :write, :delete, :clear]

    def assert_valid_module(mod)
      assert_methods_defined(mod)
    end

    def assert_valid_adapter(name)
      raise Undefined.new(name) unless definitions.key?(name.to_sym)
    end

    def assert_methods_defined(mod)
      missing_methods = []
      RequiredMethods.each do |meth|
        missing_methods << meth unless mod.method_defined?(meth)
      end
      raise IncompleteAPI.new(missing_methods) unless missing_methods.empty?
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
adapter-0.7.1 lib/adapter/asserts.rb
adapter-0.7.0 lib/adapter/asserts.rb
adapter-0.6.3 lib/adapter/asserts.rb
adapter-0.6.2 lib/adapter/asserts.rb
adapter-0.6.1 lib/adapter/asserts.rb
adapter-0.6.0 lib/adapter/asserts.rb