Class: DisposableDB::DisposableModel
- Inherits:
-
Object
- Object
- DisposableDB::DisposableModel
- Defined in:
- lib/disposable_db/disposable_model.rb
Class Method Summary collapse
Class Method Details
.build(database, table_name) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/disposable_db/disposable_model.rb', line 5 def build(database, table_name) m = Class.new(Sequel::Model(database.connection)) do set_dataset table_name.to_sym def self.database @database end def self.database=(d) @database = d end def self.transaction(opts = {}, &block) self.database.connection.transaction opts, &block end end m.database = database m end |
.factory(args = {}) ⇒ Object
30 31 32 33 34 |
# File 'lib/disposable_db/disposable_model.rb', line 30 def DisposableModel.factory(args = {}) database = args[:database] || Database.new table_name = args[:table_name] || 'disposable_table' build(database, table_name) end |