Class: DuckTyper::BulkInterfaceChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/duck_typer/bulk_interface_checker.rb

Overview

Runs interface checks across all consecutive pairs of classes in a list.

Instance Method Summary collapse

Constructor Details

#initialize(objects = nil, namespace: nil, type: :instance_methods, methods: nil, strict: false, name: nil) ⇒ BulkInterfaceChecker

Returns a new instance of BulkInterfaceChecker.



8
9
10
# File 'lib/duck_typer/bulk_interface_checker.rb', line 8

def initialize(objects = nil, namespace: nil, type: :instance_methods, methods: nil, strict: false, name: nil)
  @setup = InterfaceSetup.new(objects, namespace:, type:, methods:, strict:, name:, minimum: 2)
end

Instance Method Details

#call(&block) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/duck_typer/bulk_interface_checker.rb', line 12

def call(&block)
  @setup.objects.each_cons(2).map do |left, right|
    result = @setup.checker.call(left, right)
    block&.call(result)

    result
  end
end