Module: DatabaseCleaner::ActiveRecord::Base
- Includes:
- Generic::Base
- Included in:
- Transaction, Truncation
- Defined in:
- lib/database_cleaner/active_record/base.rb
Instance Attribute Summary collapse
-
#connection_hash ⇒ Object
Returns the value of attribute connection_hash.
Instance Method Summary collapse
Methods included from Generic::Base
Instance Attribute Details
#connection_hash ⇒ Object
Returns the value of attribute connection_hash.
23 24 25 |
# File 'lib/database_cleaner/active_record/base.rb', line 23 def connection_hash @connection_hash end |
Instance Method Details
#connection_class ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/database_cleaner/active_record/base.rb', line 41 def connection_class @connection_class ||= if db && !db.is_a?(Symbol) db elsif connection_hash lookup_from_connection_pool || establish_connection else ::ActiveRecord::Base end end |
#db ⇒ Object
30 31 32 |
# File 'lib/database_cleaner/active_record/base.rb', line 30 def db @db ||= super end |
#db=(desired_db) ⇒ Object
25 26 27 28 |
# File 'lib/database_cleaner/active_record/base.rb', line 25 def db=(desired_db) @db = desired_db load_config end |
#load_config ⇒ Object
34 35 36 37 38 39 |
# File 'lib/database_cleaner/active_record/base.rb', line 34 def load_config if self.db != :default && self.db.is_a?(Symbol) && File.file?(ActiveRecord.config_file_location) connection_details = YAML::load(ERB.new(IO.read(ActiveRecord.config_file_location)).result) @connection_hash = connection_details[self.db.to_s] end end |