Class: RR::MethodDispatches::MethodMissingDispatch
- Inherits:
-
BaseMethodDispatch
- Object
- BaseMethodDispatch
- RR::MethodDispatches::MethodMissingDispatch
- Defined in:
- lib/rr/method_dispatches/method_missing_dispatch.rb
Instance Attribute Summary collapse
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
-
#subject_class ⇒ Object
readonly
Returns the value of attribute subject_class.
Attributes inherited from BaseMethodDispatch
#args, #block, #double, #kwargs
Instance Method Summary collapse
- #call ⇒ Object
- #call_original_method ⇒ Object
-
#initialize(subject, subject_class, method_name, args, kwargs, block) ⇒ MethodMissingDispatch
constructor
A new instance of MethodMissingDispatch.
Methods included from Space::Reader
Constructor Details
#initialize(subject, subject_class, method_name, args, kwargs, block) ⇒ MethodMissingDispatch
Returns a new instance of MethodMissingDispatch.
12 13 14 15 16 17 18 19 |
# File 'lib/rr/method_dispatches/method_missing_dispatch.rb', line 12 def initialize(subject, subject_class, method_name, args, kwargs, block) @subject = subject @subject_class = subject_class @method_name = method_name @args = args @kwargs = kwargs @block = block end |
Instance Attribute Details
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
10 11 12 |
# File 'lib/rr/method_dispatches/method_missing_dispatch.rb', line 10 def method_name @method_name end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
10 11 12 |
# File 'lib/rr/method_dispatches/method_missing_dispatch.rb', line 10 def subject @subject end |
#subject_class ⇒ Object (readonly)
Returns the value of attribute subject_class.
10 11 12 |
# File 'lib/rr/method_dispatches/method_missing_dispatch.rb', line 10 def subject_class @subject_class end |
Instance Method Details
#call ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rr/method_dispatches/method_missing_dispatch.rb', line 21 def call if Injections::DoubleInjection.exists?(subject_class, method_name) @double = find_double_to_attempt if double return_value = extract_subject_from_return_value(call_implementation) if after_call_proc extract_subject_from_return_value(after_call_proc.call(return_value)) else return_value end else double_not_found_error end else call_original_method end end |
#call_original_method ⇒ Object
39 40 41 42 43 |
# File 'lib/rr/method_dispatches/method_missing_dispatch.rb', line 39 def call_original_method Injections::DoubleInjection.find_or_create(subject_class, method_name).dispatch_method_delegates_to_dispatch_original_method do call_original_method_missing end end |