Class | RR::MethodDispatches::MethodMissingDispatch |
In: |
lib/rr/method_dispatches/method_missing_dispatch.rb
|
Parent: | BaseMethodDispatch |
method_name | [R] | |
subject | [R] | |
subject_class | [R] |
# File lib/rr/method_dispatches/method_missing_dispatch.rb, line 11 11: def initialize(subject, subject_class, method_name, args, block) 12: @subject, @subject_class, @method_name, @args, @block = subject, subject_class, method_name, args, block 13: end
# File lib/rr/method_dispatches/method_missing_dispatch.rb, line 15 15: def call 16: if Injections::DoubleInjection.exists?(subject_class, method_name) 17: @double = find_double_to_attempt 18: if double 19: return_value = extract_subject_from_return_value(call_implementation) 20: if after_call_proc 21: extract_subject_from_return_value(after_call_proc.call(return_value)) 22: else 23: return_value 24: end 25: else 26: double_not_found_error 27: end 28: else 29: call_original_method 30: end 31: end
# File lib/rr/method_dispatches/method_missing_dispatch.rb, line 33 33: def call_original_method 34: Injections::DoubleInjection.find_or_create(subject_class, method_name).dispatch_method_delegates_to_dispatch_original_method do 35: call_original_method_missing 36: end 37: end
# File lib/rr/method_dispatches/method_missing_dispatch.rb, line 5 5: def original_method_missing_alias_name 6: "__rr__original_method_missing" 7: end
# File lib/rr/method_dispatches/method_missing_dispatch.rb, line 40 40: def call_implementation 41: if implementation_is_original_method? 42: space.record_call(subject, method_name, args, block) 43: double.method_call(args) 44: call_original_method 45: else 46: if double_injection = Injections::DoubleInjection.find(subject_class, method_name) 47: double_injection.bind_method 48: # The DoubleInjection takes care of calling double.method_call 49: subject.__send__(method_name, *args, &block) 50: else 51: nil 52: end 53: end 54: end