Sha256: 1dcf4a55b80d3497cd4037913081263647267a9dd506ef7af02b985645824c86

Contents?: true

Size: 944 Bytes

Versions: 3

Compression:

Stored size: 944 Bytes

Contents

module Flows
  module Plugin
    module Profiler
      # @api private
      module Injector
        class << self
          def make_module(method_name)
            Module.new.tap do |mod|
              add_included(mod, method_name)
              add_extended(mod, method_name)
            end
          end

          private

          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

          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
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flows-0.6.0 lib/flows/plugin/profiler/injector.rb
flows-0.5.1 lib/flows/plugin/profiler/injector.rb
flows-0.5.0 lib/flows/plugin/profiler/injector.rb