Class: DuckTesting::YARD::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/duck_testing/yard/builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(class_object) ⇒ Builder

Returns a new instance of Builder.

Parameters:



5
6
7
# File 'lib/duck_testing/yard/builder.rb', line 5

def initialize(class_object)
  @class_object = class_object
end

Instance Method Details

#build(scope = :instance) ⇒ Module

Build duck testing for the @class_object.

Parameters:

  • scope (Symbol) (defaults to: :instance)

    :instance or :class

Returns:

  • (Module)

    duck testing module of class_object in the scope.



13
14
15
16
17
18
19
20
21
22
# File 'lib/duck_testing/yard/builder.rb', line 13

def build(scope = :instance)
  @building_module = prepare_module
  @class_object.method_objects.each do |method_object|
    next unless method_object.scope == scope
    handle_method_object(method_object)
  end
  @building_module
ensure
  remove_instance_variable :@building_module
end