class RR::MethodDispatches::MethodDispatch
Attributes
double_injection[R]
subject[R]
Public Class Methods
new(double_injection, subject, args, block)
click to toggle source
# File lib/rr/method_dispatches/method_dispatch.rb, line 6 def initialize(double_injection, subject, args, block) @double_injection, @subject, @args, @block = double_injection, subject, args, block @double = find_double_to_attempt end
Public Instance Methods
call()
click to toggle source
# File lib/rr/method_dispatches/method_dispatch.rb, line 11 def call space.record_call(subject, method_name, args, block) if double double.method_call(args) call_yields return_value_1 = call_implementation return_value_2 = extract_subject_from_return_value(return_value_1) if after_call_proc extract_subject_from_return_value(after_call_proc.call(return_value_2)) else return_value_2 end else double_not_found_error end end
call_original_method()
click to toggle source
# File lib/rr/method_dispatches/method_dispatch.rb, line 28 def call_original_method if subject_has_original_method? subject.__send__(original_method_alias_name, *args, &block) elsif subject_has_original_method_missing? call_original_method_missing else subject.__send__(:method_missing, method_name, *args, &block) end end
Protected Instance Methods
call_implementation()
click to toggle source
# File lib/rr/method_dispatches/method_dispatch.rb, line 39 def call_implementation if implementation_is_original_method? call_original_method else if implementation if implementation.is_a?(Method) implementation.call(*args, &block) else call_args = block ? args + [ProcFromBlock.new(&block)] : args implementation.call(*call_args) end else nil end end end