Module: Contrast::Utils::Patching::PatcherUtils
- Included in:
- Agent::Patching::Policy::Patcher
- Defined in:
- lib/contrast/utils/patching/policy/patcher_utils.rb
Overview
This module will include patch methods from Patcher module in case of need to add new logic to the Patcher please do it here
Instance Method Summary collapse
-
#patch_method(mod, methods, method_policy) ⇒ Boolean
We did it, team.
-
#patch_specific_module(mod) ⇒ Object
This method is called by TracePointHook to instrument a specific class during a require or eval of dynamic class definition.
Instance Method Details
#patch_method(mod, methods, method_policy) ⇒ Boolean
We did it, team. We found a patcher(s) that applies to the given class (or module) and the given method. Time to do some tracking.
42 43 44 45 46 47 48 49 50 |
# File 'lib/contrast/utils/patching/policy/patcher_utils.rb', line 42 def patch_method mod, methods, method_policy return false unless methods&.any? # don't even build the name if there are no methods if Contrast::Utils::ClassUtil.prepended_method?(mod, method_policy) Contrast::Agent::Patching::Policy::Patch.instrument_with_prepend(mod, method_policy) else Contrast::Agent::Patching::Policy::Patch.instrument_with_alias(mod, methods, method_policy) end end |
#patch_specific_module(mod) ⇒ Object
This method is called by TracePointHook to instrument a specific class during a require or eval of dynamic class definition
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/contrast/utils/patching/policy/patcher_utils.rb', line 13 def patch_specific_module mod with_contrast_scope do mod_name = mod.cs__name return unless Contrast::Utils::ClassUtil.truly_defined?(mod_name) return if ::Contrast::AGENT.skip_instrumentation?(mod_name) load_patches_for_module(mod_name) return if all_module_names.none?(mod_name) module_data = Contrast::Agent::ModuleData.new(mod, mod_name) patch_into_module(module_data) all_module_names.delete(mod_name) if status_type.get_status(mod).patched? rescue StandardError => e logger.error('Unable to patch module', e, module: mod_name) end end |