Class: DbBackupTool::Mappers::ActiveRecordMapper
- Inherits:
-
Object
- Object
- DbBackupTool::Mappers::ActiveRecordMapper
- Defined in:
- lib/db_backup_tool/mappers/active_record_mapper.rb
Defined Under Namespace
Classes: Table
Instance Method Summary collapse
-
#connection ⇒ Object
:internal.
-
#initialize(config) ⇒ ActiveRecordMapper
constructor
Constructor.
-
#tables ⇒ Object
Return tables (proxy) in the database.
Constructor Details
#initialize(config) ⇒ ActiveRecordMapper
Constructor
6 7 8 9 10 11 |
# File 'lib/db_backup_tool/mappers/active_record_mapper.rb', line 6 def initialize(config) @orm = Class.new(ActiveRecord::Base) { self.abstract_class = true establish_connection(config) } end |
Instance Method Details
#connection ⇒ Object
:internal
14 15 16 |
# File 'lib/db_backup_tool/mappers/active_record_mapper.rb', line 14 def connection @orm.connection end |
#tables ⇒ Object
Return tables (proxy) in the database
19 20 21 22 23 |
# File 'lib/db_backup_tool/mappers/active_record_mapper.rb', line 19 def tables table_names = @orm.connection.tables.dup table_names.reject! {|t| %w(schema_info schema_migrations).include? t } Hash[ table_names.map {|t| [t, Table.new(@orm, t)] } ].freeze end |