module Dry::ResultMatcher

Constants

VERSION

Public Class Methods

for(*match_methods) click to toggle source
Calls superclass method
# File lib/dry/result_matcher.rb, line 9
def self.for(*match_methods)
  matchers_mod = Module.new do
    match_methods.each do |match_method|
      define_method(match_method) do |*args, &block|
        result = super(*args)

        if block
          Dry::ResultMatcher.match(result, &block)
        else
          result
        end
      end
    end
  end

  Module.new do
    const_set :Matchers, matchers_mod

    def self.included(klass)
      klass.prepend const_get(:Matchers)
    end
  end
end
included(klass) click to toggle source
# File lib/dry/result_matcher.rb, line 27
def self.included(klass)
  klass.prepend const_get(:Matchers)
end
match(result, &block) click to toggle source
# File lib/dry/result_matcher.rb, line 5
def self.match(result, &block)
  block.call(Matcher.new(result))
end