module Flows::Plugin::Profiler::Injector

@api private

Public Class Methods

make_module(method_name) click to toggle source
# File lib/flows/plugin/profiler/injector.rb, line 7
def make_module(method_name)
  Module.new.tap do |mod|
    add_included(mod, method_name)
    add_extended(mod, method_name)
  end
end

Private Class Methods

add_extended(mod, method_name) click to toggle source
# File lib/flows/plugin/profiler/injector.rb, line 24
def add_extended(mod, method_name)
  mod.define_method(:extended) do |target|
    raise 'must be extended into class' unless target.is_a?(Class)

    target.singleton_class.prepend(Wrapper.make_singleton_wrapper(method_name))
  end
end
add_included(mod, method_name) click to toggle source
# File lib/flows/plugin/profiler/injector.rb, line 16
def add_included(mod, method_name)
  mod.define_method(:included) do |target|
    raise 'must be included into class' unless target.is_a?(Class)

    target.prepend Wrapper.make_instance_wrapper(method_name)
  end
end