Class: MethodCallCount::CallableStub

Inherits:
Object
  • Object
show all
Defined in:
lib/method_call_count/callable_stub.rb

Instance Method Summary collapse

Constructor Details

#initialize(value = nil, &block) ⇒ CallableStub

Returns a new instance of CallableStub.



5
6
7
8
# File 'lib/method_call_count/callable_stub.rb', line 5

def initialize(value = nil, &block)
  @block = value.nil? ? block : ->(options){value}
  @called_with = {}
end

Instance Method Details

#call(options = {}) ⇒ Object



9
10
11
12
# File 'lib/method_call_count/callable_stub.rb', line 9

def call(options={})
  @called_with = options
  @block&.call(options)
end

#called_withObject



13
14
15
# File 'lib/method_call_count/callable_stub.rb', line 13

def called_with
  @called_with.dup
end