Class: WordNet::Model
- Inherits:
-
Sequel::Model
- Object
- Sequel::Model
- WordNet::Model
- Extended by:
- Loggability
- Defined in:
- lib/wordnet/model.rb
Overview
The base WordNet database-backed domain class. It’s a subclass of Sequel::Model, so you’ll first need to be familiar with Sequel (sequel.rubyforge.org/) and especially its Sequel::Model ORM.
Class Method Summary collapse
-
.db=(newdb) ⇒ Object
Reset the database connection that all model objects will use.
-
.without_sql_logging(logged_db = nil) ⇒ Object
Execute a block after removing all loggers from the current database handle, then restore them before returning.
Class Method Details
.db=(newdb) ⇒ Object
Reset the database connection that all model objects will use.
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/wordnet/model.rb', line 43 def self::db=( newdb ) self.without_sql_logging( newdb ) do super end self.descendents.each do |subclass| self.log.debug "Resetting database connection for: %p to: %p" % [ subclass, newdb ] subclass.db = newdb end end |
.without_sql_logging(logged_db = nil) ⇒ Object
Execute a block after removing all loggers from the current database handle, then restore them before returning.
30 31 32 33 34 35 36 37 38 |
# File 'lib/wordnet/model.rb', line 30 def self::without_sql_logging( logged_db=nil ) logged_db ||= self.db loggers_to_restore = logged_db.loggers.dup logged_db.loggers.clear yield ensure logged_db.loggers.replace( loggers_to_restore ) end |