Class RR::MethodDispatches::MethodDispatch
In: lib/rr/method_dispatches/method_dispatch.rb
Parent: BaseMethodDispatch

Methods

Attributes

double_injection  [R] 
subject  [R] 

Public Class methods

[Source]

   # File lib/rr/method_dispatches/method_dispatch.rb, line 5
5:       def initialize(double_injection, subject, args, block)
6:         @double_injection, @subject, @args, @block = double_injection, subject, args, block
7:         @double = find_double_to_attempt
8:       end

Public Instance methods

[Source]

    # File lib/rr/method_dispatches/method_dispatch.rb, line 10
10:       def call
11:         space.record_call(subject, method_name, args, block)
12:         if double
13:           double.method_call(args)
14:           call_yields
15:           return_value_1 = call_implementation
16:           return_value_2 = extract_subject_from_return_value(return_value_1)
17:           if after_call_proc
18:             extract_subject_from_return_value(after_call_proc.call(return_value_2))
19:           else
20:             return_value_2
21:           end
22:         else
23:           double_not_found_error
24:         end
25:       end

[Source]

    # File lib/rr/method_dispatches/method_dispatch.rb, line 27
27:       def call_original_method
28:         if subject_has_original_method?
29:           subject.__send__(original_method_alias_name, *args, &block)
30:         elsif subject_has_original_method_missing?
31:           call_original_method_missing
32:         else
33:           subject.__send__(:method_missing, method_name, *args, &block)
34:         end
35:       end

Protected Instance methods

[Source]

    # File lib/rr/method_dispatches/method_dispatch.rb, line 38
38:       def call_implementation
39:         if implementation_is_original_method?
40:           call_original_method
41:         else
42:           if implementation
43:             if implementation.is_a?(Method)
44:               implementation.call(*args, &block)
45:             else
46:               call_args = block ? args + [ProcFromBlock.new(&block)] : args
47:               implementation.call(*call_args)
48:             end
49:           else
50:             nil
51:           end
52:         end
53:       end

[Validate]