Module: BranchDb::RealDbSwitchersCommon::ClassMethods
- Defined in:
- lib/branch_db/real_db_switchers_common.rb
Instance Method Summary collapse
- #branch_dbs ⇒ Object
- #existing_databases ⇒ Object
- #find_existing_databases ⇒ Object
- #reset_existing_databases ⇒ Object
- #show_branches(rails_env, config) ⇒ Object
Instance Method Details
#branch_dbs ⇒ Object
10 11 12 |
# File 'lib/branch_db/real_db_switchers_common.rb', line 10 def branch_dbs existing_databases.grep end |
#existing_databases ⇒ Object
18 19 20 |
# File 'lib/branch_db/real_db_switchers_common.rb', line 18 def existing_databases @existing_databases ||= find_existing_databases end |
#find_existing_databases ⇒ Object
14 15 16 |
# File 'lib/branch_db/real_db_switchers_common.rb', line 14 def find_existing_databases raise Error, "Classes including RealDbSwitchersCommon must implement #find_existing_databases." end |
#reset_existing_databases ⇒ Object
22 23 24 |
# File 'lib/branch_db/real_db_switchers_common.rb', line 22 def reset_existing_databases @existing_databases = nil end |
#show_branches(rails_env, config) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/branch_db/real_db_switchers_common.rb', line 26 def show_branches(rails_env, config) case per_branch = config['per_branch'] when true master_db = config['database'] pat = master_db.split(/[_-]/).join('(?:(?:[-_]+)|(?:[-_]+[-_\w]+?[-_]+))') dbs = existing_databases.grep(/^#{pat}$/) puts "#{rails_env}: #{dbs.join(', ')}." end end |