Class: Spy::MethodCall

Inherits:
Object
  • Object
show all
Defined in:
lib/spy/method_call.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spy, receiver, args, block, backtrace) ⇒ MethodCall

Returns a new instance of MethodCall.



5
6
7
8
9
10
11
# File 'lib/spy/method_call.rb', line 5

def initialize(spy, receiver, args, block, backtrace)
  @spy = spy
  @receiver = receiver
  @args = args
  @block = block
  @backtrace = backtrace
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



3
4
5
# File 'lib/spy/method_call.rb', line 3

def args
  @args
end

#backtraceObject (readonly) Also known as: caller

Returns the value of attribute backtrace.



3
4
5
# File 'lib/spy/method_call.rb', line 3

def backtrace
  @backtrace
end

#blockObject (readonly)

Returns the value of attribute block.



3
4
5
# File 'lib/spy/method_call.rb', line 3

def block
  @block
end

#receiverObject (readonly)

Returns the value of attribute receiver.



3
4
5
# File 'lib/spy/method_call.rb', line 3

def receiver
  @receiver
end

#resultObject (readonly)

Returns the value of attribute result.



3
4
5
# File 'lib/spy/method_call.rb', line 3

def result
  @result
end

#spyObject (readonly)

Returns the value of attribute spy.



3
4
5
# File 'lib/spy/method_call.rb', line 3

def spy
  @spy
end

Instance Method Details

#call_original(persist_result = false) ⇒ Object Also known as: replay



17
18
19
20
21
# File 'lib/spy/method_call.rb', line 17

def call_original(persist_result = false)
  result = @spy.call_original(@receiver, @args, @block)
  @result = result if persist_result
  result
end

#nameObject



13
14
15
# File 'lib/spy/method_call.rb', line 13

def name
  @spy.original.name
end