Class: NotAMock::StubMethod

Inherits:
Object show all
Defined in:
lib/not_a_mock/stubmethod.rb

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ StubMethod

Returns a new instance of StubMethod.



5
6
7
8
# File 'lib/not_a_mock/stubmethod.rb', line 5

def initialize(&block)
	@block = block
	@yield_values = []
end

Instance Method Details

#execute_return_block(*args) ⇒ Object



15
16
17
18
19
# File 'lib/not_a_mock/stubmethod.rb', line 15

def execute_return_block(*args)
	return_value = nil
	(return_value = @block.call(*args)) unless @block.nil?
	return_value
end

#yield_to_block(&block) ⇒ Object



21
22
23
24
# File 'lib/not_a_mock/stubmethod.rb', line 21

def yield_to_block(&block)
	return if block.nil?
	block.call(*@yield_values)
end

#yields(*args, &block) ⇒ Object



10
11
12
13
# File 'lib/not_a_mock/stubmethod.rb', line 10

def yields(*args, &block)
	@yield_values = args
	(@block = block) unless block.nil?
end