Class: EvalHook::MultiHookHandler
- Inherits:
-
HookHandler
- Object
- HookHandler
- EvalHook::MultiHookHandler
- Defined in:
- lib/evalhook/multi_hook_handler.rb
Instance Attribute Summary
Attributes inherited from HookHandler
Instance Method Summary collapse
-
#add(nested_hh) ⇒ Object
Add a nested hook handler to the hook handler chain (see examples).
- #handle_cdecl(*args) ⇒ Object
- #handle_gasgn(*args) ⇒ Object
- #handle_method(klass, recv, method_id) ⇒ Object
- #handle_xstr(str) ⇒ Object
-
#initialize ⇒ MultiHookHandler
constructor
A new instance of MultiHookHandler.
Methods inherited from HookHandler
#dispose, #evalhook, #evalhook_i, #handle_colon2, #handle_colon3, #handle_const, #handle_gvar, #hooked_cdecl, #hooked_colon2, #hooked_const, #hooked_gasgn, #hooked_gvar, #hooked_method, #hooked_variable_method, #hooked_xstr, #internal_eval, #packet, #partialruby_context, #private_method_check
Methods included from RedirectHelper
#const_value, #global_value, #redirect_cdecl, #redirect_gasgn, #redirect_method
Constructor Details
#initialize ⇒ MultiHookHandler
Returns a new instance of MultiHookHandler.
28 29 30 |
# File 'lib/evalhook/multi_hook_handler.rb', line 28 def initialize @nested_hook_handlers = Array.new end |
Instance Method Details
#add(nested_hh) ⇒ Object
Add a nested hook handler to the hook handler chain (see examples)
33 34 35 |
# File 'lib/evalhook/multi_hook_handler.rb', line 33 def add(nested_hh) @nested_hook_handlers << nested_hh end |
#handle_cdecl(*args) ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/evalhook/multi_hook_handler.rb', line 55 def handle_cdecl(*args) lastret = nil @nested_hook_handlers.each do |hh| currret = hh.handle_cdecl(*args) lastret = currret || lastret end lastret end |
#handle_gasgn(*args) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/evalhook/multi_hook_handler.rb', line 66 def handle_gasgn(*args) lastret = nil @nested_hook_handlers.each do |hh| currret = hh.handle_gasgn(*args) lastret = currret || lastret end lastret end |
#handle_method(klass, recv, method_id) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/evalhook/multi_hook_handler.rb', line 37 def handle_method(klass, recv, method_id) lastret = nil @nested_hook_handlers.each do |hh| currret = hh.handle_method(klass, recv, method_id) lastret = currret || lastret if (currret) klass = currret.klass recv = currret.recv method_id = currret.method_name end end lastret end |
#handle_xstr(str) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/evalhook/multi_hook_handler.rb', line 78 def handle_xstr(str) lastret = nil @nested_hook_handlers.each do |hh| lastret = hh.handle_xstr(str) str = lastret || str end lastret end |