Method: Correspondent#method_added
- Defined in:
- lib/correspondent.rb
#method_added(name) ⇒ Object
method_added
Callback to patch methods once they are defined.
-
Create an alias of the original method
-
Override method by calling the original
-
Add Correspondent calls for notifications
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/correspondent.rb', line 91 def method_added(name) patch_info = Correspondent.patched_methods.delete(name) return unless patch_info class_eval(<<~PATCH, __FILE__, __LINE__ + 1) alias_method :original_#{name}, :#{name} def #{name}(*args, &block) result = original_#{name}(*args, &block) #{build_async_calls(patch_info, name)} result end PATCH super end |