Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
def get_use_db_conn_spec(options) options.symbolize_keys suffix = options.delete(:suffix) prefix = options.delete(:prefix) rails_env = options.delete(:rails_env) || RAILS_ENV connection_options = options if (connection_options[:adapter]) return connection_options else str = "#{prefix}#{rails_env}#{suffix}" connections = YAML.load(File.read "#{RAILS_ROOT}/config/database.yml") raise "Cannot find database specification. Configuration '#{str}' expected in config/database.yml" if (connections[str].nil?) connection_options = connections[str] end connection_options.merge(options.stringify_keys) end
This paste will be private.
From the Design Piracy series on my blog: