Module: PedantMysql2
- Defined in:
- lib/pedant_mysql2.rb,
lib/pedant_mysql2/version.rb
Constant Summary collapse
- VERSION =
'1.0.1'
Class Attribute Summary collapse
-
.on_warning ⇒ Object
Returns the value of attribute on_warning.
Class Method Summary collapse
- .capture_warnings ⇒ Object
- .ignore(*matchers) ⇒ Object
- .ignored?(warning) ⇒ Boolean
- .raise_warnings! ⇒ Object
- .silence_warnings! ⇒ Object
Class Attribute Details
.on_warning ⇒ Object
Returns the value of attribute on_warning.
3 4 5 |
# File 'lib/pedant_mysql2.rb', line 3 def on_warning @on_warning end |
Class Method Details
.capture_warnings ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/pedant_mysql2.rb', line 5 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 |
.ignore(*matchers) ⇒ Object
26 27 28 |
# File 'lib/pedant_mysql2.rb', line 26 def ignore(*matchers) self.whitelist.concat(matchers.flatten) end |
.ignored?(warning) ⇒ Boolean
30 31 32 |
# File 'lib/pedant_mysql2.rb', line 30 def ignored?(warning) on_warning.nil? || whitelist.any? { |matcher| matcher =~ warning. } end |
.raise_warnings! ⇒ Object
18 19 20 |
# File 'lib/pedant_mysql2.rb', line 18 def raise_warnings! self.on_warning = lambda{ |warning| raise warning } end |
.silence_warnings! ⇒ Object
22 23 24 |
# File 'lib/pedant_mysql2.rb', line 22 def silence_warnings! self.on_warning = nil end |