Module: Isolator::AdapterBuilder
- Defined in:
- lib/isolator/adapter_builder.rb
Overview
Builds adapter from provided params
Class Method Summary collapse
- .add_patch_method(adapter, base, method_name) ⇒ Object
- .call(target: nil, method_name: nil, **options) ⇒ Object
Class Method Details
.add_patch_method(adapter, base, method_name) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/isolator/adapter_builder.rb', line 21 def self.add_patch_method(adapter, base, method_name) mod = Module.new do define_method method_name do |*args, &block| adapter.notify(caller, *args) super(*args, &block) end end base.prepend mod end |
.call(target: nil, method_name: nil, **options) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/isolator/adapter_builder.rb', line 8 def self.call(target: nil, method_name: nil, **) adapter = Module.new do extend Isolator::Adapters::Base self.exception_class = [:exception_class] if .key?(:exception_class) self. = [:exception_message] if .key?(:exception_message) end add_patch_method(adapter, target, method_name) if target && method_name adapter end |