Sha256: babb59cc067f19c28b1bab420459c8f5326ebc7981fe75d41f6a742fb065f49b
Contents?: true
Size: 961 Bytes
Versions: 2
Compression:
Stored size: 961 Bytes
Contents
module PedantMysql2 class << self attr_accessor :on_warning def capture_warnings previous_callback = on_warning previous_warnings = Thread.current[:mysql_warnings] Thread.current[:mysql_warnings] = [] self.on_warning = lambda { |warning| Thread.current[:mysql_warnings] << warning } yield warnings = Thread.current[:mysql_warnings] warnings ensure Thread.current[:mysql_warnings] = previous_warnings self.on_warning = previous_callback end def raise_warnings! self.on_warning = lambda{ |warning| raise warning } end def silence_warnings! self.on_warning = nil end def ignore(*matchers) self.whitelist.concat(matchers.flatten) end def ignored?(warning) on_warning.nil? || whitelist.any? { |matcher| matcher =~ warning.message } end protected def whitelist @whitelist ||= [] end end raise_warnings! end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
activerecord-pedantmysql2-adapter-1.0.1 | lib/pedant_mysql2.rb |
activerecord-pedantmysql2-adapter-1.0.0 | lib/pedant_mysql2.rb |