lib/isolator/adapter_builder.rb in isolator-0.1.0.pre2 vs lib/isolator/adapter_builder.rb in isolator-0.1.0

- old
+ new

@@ -3,25 +3,26 @@ require "isolator/adapters/base" module Isolator # Builds adapter from provided params module AdapterBuilder - def self.call(target, method_name, **options) + def self.call(target: nil, method_name: nil, **options) adapter = Module.new do extend Isolator::Adapters::Base self.exception_class = options[:exception_class] if options.key?(:exception_class) self.exception_message = options[:exception_message] if options.key?(:exception_message) end - add_patch_method adapter, target, method_name + add_patch_method(adapter, target, method_name) if + target && method_name adapter end def self.add_patch_method(adapter, base, method_name) mod = Module.new do define_method method_name do |*args, &block| - adapter.notify(caller) if adapter.notify_isolator? + adapter.notify(caller, *args) super(*args, &block) end end base.prepend mod