Class: RR::MethodDispatches::MethodDispatch
- Inherits:
-
BaseMethodDispatch
- Object
- BaseMethodDispatch
- RR::MethodDispatches::MethodDispatch
- Defined in:
- lib/rr/method_dispatches/method_dispatch.rb
Instance Attribute Summary collapse
-
#double_injection ⇒ Object
readonly
Returns the value of attribute double_injection.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Attributes inherited from BaseMethodDispatch
Instance Method Summary collapse
- #call ⇒ Object
- #call_original_method ⇒ Object
-
#initialize(double_injection, subject, args, block) ⇒ MethodDispatch
constructor
A new instance of MethodDispatch.
Methods included from Space::Reader
Constructor Details
#initialize(double_injection, subject, args, block) ⇒ MethodDispatch
Returns a new instance of MethodDispatch.
5 6 7 8 |
# File 'lib/rr/method_dispatches/method_dispatch.rb', line 5 def initialize(double_injection, subject, args, block) @double_injection, @subject, @args, @block = double_injection, subject, args, block @double = find_double_to_attempt end |
Instance Attribute Details
#double_injection ⇒ Object (readonly)
Returns the value of attribute double_injection.
4 5 6 |
# File 'lib/rr/method_dispatches/method_dispatch.rb', line 4 def double_injection @double_injection end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
4 5 6 |
# File 'lib/rr/method_dispatches/method_dispatch.rb', line 4 def subject @subject end |
Instance Method Details
#call ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rr/method_dispatches/method_dispatch.rb', line 10 def call space.record_call(subject, method_name, args, block) if double double.method_call(args) call_yields return_value_1 = call_implementation return_value_2 = extract_subject_from_return_value(return_value_1) if after_call_proc extract_subject_from_return_value(after_call_proc.call(return_value_2)) else return_value_2 end else double_not_found_error end end |
#call_original_method ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/rr/method_dispatches/method_dispatch.rb', line 27 def call_original_method if subject_has_original_method? subject.__send__(original_method_alias_name, *args, &block) elsif subject_has_original_method_missing? call_original_method_missing else subject.__send__(:method_missing, method_name, *args, &block) end end |