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: call_yields 20: return_value = extract_subject_from_return_value(call_implementation) 21: if after_call_proc 22: extract_subject_from_return_value(after_call_proc.call(return_value)) 23: else 24: return_value 25: end 26: else 27: double_not_found_error 28: end 29: else 30: call_original_method 31: end 32: end
# File lib/rr/method_dispatches/method_missing_dispatch.rb, line 34 34: def call_original_method 35: Injections::DoubleInjection.find_or_create(subject_class, method_name).dispatch_method_delegates_to_dispatch_original_method do 36: call_original_method_missing 37: end 38: 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 41 41: def call_implementation 42: if implementation_is_original_method? 43: space.record_call(subject, method_name, args, block) 44: double.method_call(args) 45: call_original_method 46: else 47: if double_injection = Injections::DoubleInjection.find(subject_class, method_name) 48: double_injection.bind_method 49: # The DoubleInjection takes care of calling double.method_call 50: subject.__send__(method_name, *args, &block) 51: else 52: nil 53: end 54: end 55: end