Sha256: 15efc3528d63514de7b58b50d97b475286f8e96077d46f18af9e49e7260542aa
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
require 'set' module RR module Integrations end def self.register_adapter(klass) adapter = Integrations::Decorator.new(klass.new) unless adapters_by_name.key?(adapter.name) adapters << adapter adapters_by_name[adapter.name] = adapter end end def self.adapters @adapters ||= [] end def self.adapters_by_name @adapters_by_name ||= {} end def self.loaded_adapter_names adapters. select { |adapter| adapter.loaded? }. map { |adapter| adapter.name } end def self.applicable_adapters adapters.select { |adapter| adapter.applies? } end def self.find_applicable_adapter_matching(pattern) adapter = adapters. select { |adapter| adapter.name.to_s =~ pattern }. find { |adapter| adapter.applies? } if adapter mod = Module.new (class << mod; self; end).class_eval do define_method(:included) do |base| # Note: This assumes that the thing that is including this module # is the same that the adapter detected and will hook into. adapter.hook end end mod end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rr-1.1.1 | lib/rr/integrations.rb |
rr-1.1.1.rc1 | lib/rr/integrations.rb |