Skip to content

Commit

Permalink
Store all databases connected to in hash.
Browse files Browse the repository at this point in the history
  • Loading branch information
bhauff committed Nov 4, 2010
1 parent b2897ba commit 4dc31cd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/sequel-rails/railtie.rb
Expand Up @@ -48,7 +48,7 @@ class Railtie < Rails::Railtie
end

initializer "sequel.connect" do |app|
Rails::Sequel.setup(Rails.env)
Rails::Sequel.database(Rails.env)
end

# Run setup code after_initialize to make sure all config/initializers
Expand Down
13 changes: 8 additions & 5 deletions lib/sequel-rails/setup.rb
Expand Up @@ -8,12 +8,15 @@

module Rails
module Sequel

@databases = {}

def self.setup(environment)
puts "[sequel] Setting up the #{environment.inspect} environment:"

::Sequel.connect({:logger => configuration.logger}.merge(::Rails::Sequel.configuration.environment_for(environment.to_s)))
config = ::Rails::Sequel.configuration.environment_for(environment.to_s)
::Sequel.connect({:logger => configuration.logger}.merge(config))
end

def self.database(name)
@databases[name] ||= setup(name)
end

end
end

0 comments on commit 4dc31cd

Please sign in to comment.