module Isolator::AdapterBuilder

Builds adapter from provided params

Public Class Methods

add_patch_method(adapter, base, method_name) click to toggle source
Calls superclass method
# File lib/isolator/adapter_builder.rb, line 22
def self.add_patch_method(adapter, base, method_name)
  mod = Module.new do
    define_method method_name do |*args, &block|
      adapter.notify(caller, self, *args)
      super(*args, &block)
    end
  end

  base.prepend mod
end
call(target: nil, method_name: nil, **options) click to toggle source
# File lib/isolator/adapter_builder.rb, line 8
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)
    self.details_message = options[:details_message] if options.key?(:details_message)
  end

  add_patch_method(adapter, target, method_name) if
    target && method_name
  adapter
end