Permalink
Browse files

Moved DoubleInjection#call_original_method and #call_method_missing t…

…o DoubleInjectionDispatch.
  • Loading branch information...
btakita committed Sep 8, 2009
1 parent 3a9d772 commit a6a3908f5425dda440c8929ba66bb02e9e74a374
Showing with 18 additions and 14 deletions.
  1. +2 −10 lib/rr/double_injection.rb
  2. +16 −4 lib/rr/double_injection_dispatch.rb
View
@@ -95,12 +95,8 @@ def dispatch_method(args, block)
DoubleInjectionDispatch.new(self, args, block).call
end
- def call_original_method(args, block)
- subject.__send__(original_method_alias_name, *args, &block)
- end
-
- def call_method_missing(args, block)
- subject.__send__(:method_missing, method_name, *args, &block)
+ def original_method_alias_name
+ "__rr__original_#{@method_name}"
end
protected
@@ -124,10 +120,6 @@ def #{@method_name}(*args, &block)
subject_class.class_eval(returns_method, __FILE__, __LINE__ - 5)
end
- def original_method_alias_name
- "__rr__original_#{@method_name}"
- end
-
def original_singleton_method_added_alias_name
"__rr__original_singleton_method_added"
end
@@ -69,7 +69,7 @@ def call_implementation
def get_implementation_return_value
if implementation_is_original_method?
- call_original_method
+ send_original_method_name
else
if implementation
if implementation.is_a?(Method)
@@ -88,14 +88,22 @@ def implementation_is_original_method?
double.implementation_is_original_method?
end
- def call_original_method
+ def send_original_method_name
if subject_has_original_method?
- double_injection.call_original_method(args, block)
+ call_original_method
else
- double_injection.call_method_missing(args, block)
+ call_method_missing
end
end
+ def call_original_method
+ subject.__send__(original_method_alias_name, *args, &block)
+ end
+
+ def call_method_missing
+ subject.__send__(:method_missing, method_name, *args, &block)
+ end
+
def extract_subject_from_return_value(return_value)
case return_value
when DoubleDefinitions::DoubleDefinition
@@ -133,6 +141,10 @@ def method_name
double_injection.method_name
end
+ def original_method_alias_name
+ double_injection.original_method_alias_name
+ end
+
def doubles
double_injection.doubles
end

0 comments on commit a6a3908

Please sign in to comment.