class RR::MethodDispatches::BaseMethodDispatch
Attributes
args[R]
block[R]
double[R]
Public Instance Methods
call()
click to toggle source
# File lib/rr/method_dispatches/base_method_dispatch.rb, line 9 def call raise NotImplementedError end
Protected Instance Methods
call_original_method_missing()
click to toggle source
# File lib/rr/method_dispatches/base_method_dispatch.rb, line 50 def call_original_method_missing subject.__send__(MethodMissingDispatch.original_method_missing_alias_name, method_name, *args, &block) end
call_yields()
click to toggle source
# File lib/rr/method_dispatches/base_method_dispatch.rb, line 40 def call_yields if definition.yields_value if block block.call(*definition.yields_value) else raise ArgumentError, "A Block must be passed into the method call when using yields" end end end
double_not_found_error()
click to toggle source
# File lib/rr/method_dispatches/base_method_dispatch.rb, line 69 def double_not_found_error message = "On subject #{subject},\n" << "unexpected method invocation:\n" << " #{Double.formatted_name(method_name, args)}\n" << "expected invocations:\n" << Double.list_message_part(doubles) raise RR::Errors.build_error(:DoubleNotFoundError, message) end
extract_subject_from_return_value(return_value)
click to toggle source
# File lib/rr/method_dispatches/base_method_dispatch.rb, line 58 def extract_subject_from_return_value(return_value) case return_value when DoubleDefinitions::DoubleDefinition return_value.root_subject when DoubleDefinitions::DoubleDefinitionCreateBlankSlate return_value.__double_definition_create__.root_subject else return_value end end
find_double_to_attempt()
click to toggle source
# File lib/rr/method_dispatches/base_method_dispatch.rb, line 14 def find_double_to_attempt matches = DoubleMatches.new(doubles).find_all_matches(args) unless matches.exact_terminal_doubles_to_attempt.empty? return matches.exact_terminal_doubles_to_attempt.first end unless matches.exact_non_terminal_doubles_to_attempt.empty? return matches.exact_non_terminal_doubles_to_attempt.last end unless matches.wildcard_terminal_doubles_to_attempt.empty? return matches.wildcard_terminal_doubles_to_attempt.first end unless matches.wildcard_non_terminal_doubles_to_attempt.empty? return matches.wildcard_non_terminal_doubles_to_attempt.last end unless matches.matching_doubles.empty? return matches.matching_doubles.first # This will raise a TimesCalledError end return nil end
implementation_is_original_method?()
click to toggle source
# File lib/rr/method_dispatches/base_method_dispatch.rb, line 54 def implementation_is_original_method? double.implementation_is_original_method? end