| Class | RR::MethodDispatches::BaseMethodDispatch |
| In: |
lib/rr/method_dispatches/base_method_dispatch.rb
|
| Parent: | Object |
| args | [R] | |
| block | [R] | |
| double | [R] |
# File lib/rr/method_dispatches/base_method_dispatch.rb, line 9
9: def call
10: raise NotImplementedError
11: end
# File lib/rr/method_dispatches/base_method_dispatch.rb, line 50
50: def call_original_method_missing
51: subject.__send__(MethodMissingDispatch.original_method_missing_alias_name, method_name, *args, &block)
52: end
# File lib/rr/method_dispatches/base_method_dispatch.rb, line 40
40: def call_yields
41: if definition.yields_value
42: if block
43: block.call(*definition.yields_value)
44: else
45: raise ArgumentError, "A Block must be passed into the method call when using yields"
46: end
47: end
48: end
# File lib/rr/method_dispatches/base_method_dispatch.rb, line 69
69: def double_not_found_error
70: message =
71: "On subject #{subject},\n" <<
72: "unexpected method invocation:\n" <<
73: " #{Double.formatted_name(method_name, args)}\n" <<
74: "expected invocations:\n" <<
75: Double.list_message_part(doubles)
76: raise Errors::DoubleNotFoundError, message
77: end
# File lib/rr/method_dispatches/base_method_dispatch.rb, line 58
58: def extract_subject_from_return_value(return_value)
59: case return_value
60: when DoubleDefinitions::DoubleDefinition
61: return_value.root_subject
62: when DoubleDefinitions::DoubleDefinitionCreateBlankSlate
63: return_value.__double_definition_create__.root_subject
64: else
65: return_value
66: end
67: end
# File lib/rr/method_dispatches/base_method_dispatch.rb, line 14
14: def find_double_to_attempt
15: matches = DoubleMatches.new(doubles).find_all_matches(args)
16:
17: unless matches.exact_terminal_doubles_to_attempt.empty?
18: return matches.exact_terminal_doubles_to_attempt.first
19: end
20:
21: unless matches.exact_non_terminal_doubles_to_attempt.empty?
22: return matches.exact_non_terminal_doubles_to_attempt.last
23: end
24:
25: unless matches.wildcard_terminal_doubles_to_attempt.empty?
26: return matches.wildcard_terminal_doubles_to_attempt.first
27: end
28:
29: unless matches.wildcard_non_terminal_doubles_to_attempt.empty?
30: return matches.wildcard_non_terminal_doubles_to_attempt.last
31: end
32:
33: unless matches.matching_doubles.empty?
34: return matches.matching_doubles.first # This will raise a TimesCalledError
35: end
36:
37: return nil
38: end