class Dry::System::Plugins::Monitoring::Proxy
@api private
Public Class Methods
for(target, key:, methods: [])
click to toggle source
@api private
# File lib/dry/system/plugins/monitoring/proxy.rb, line 12 def self.for(target, key:, methods: []) monitored_methods = if methods.empty? target.public_methods - Object.public_instance_methods else methods end Class.new(self) do extend Dry::Core::ClassAttributes include Dry::Events::Publisher[target.class.name] defines :monitored_methods attr_reader :__notifications__ monitored_methods(monitored_methods) monitored_methods.each do |meth| define_method(meth) do |*args, &block| object = __getobj__ opts = {target: key, object: object, method: meth, args: args} __notifications__.instrument(:monitoring, opts) do object.public_send(meth, *args, &block) end end end end end
new(target, notifications)
click to toggle source
Calls superclass method
# File lib/dry/system/plugins/monitoring/proxy.rb, line 43 def initialize(target, notifications) super(target) @__notifications__ = notifications end