Module: Rmre::DynamicDb
Class Method Summary collapse
Instance Method Summary collapse
- #connection_options ⇒ Object
- #connection_options=(v) ⇒ Object
- #create_model_for(table_name, primary_key_name) ⇒ Object
Class Method Details
Instance Method Details
#connection_options ⇒ Object
9 10 11 |
# File 'lib/rmre/dynamic_db.rb', line 9 def @connection_options end |
#connection_options=(v) ⇒ Object
13 14 15 |
# File 'lib/rmre/dynamic_db.rb', line 13 def v @connection_options = v end |
#create_model_for(table_name, primary_key_name) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rmre/dynamic_db.rb', line 17 def create_model_for(table_name, primary_key_name) model_name = table_name.classify module_eval <<-ruby_src, __FILE__, __LINE__ + 1 class #{model_name} < Db self.table_name = '#{table_name}' establish_connection(#{}) end ruby_src klass = const_get model_name klass.primary_key = primary_key_name if primary_key_name && primary_key_name != 'id' klass end |