Permalink
Browse files

Trim whitespace

  • Loading branch information...
1 parent 95cc378 commit db0ed7f39d9d81acb0aa048e8b5024178567f321 @pusewicz committed Aug 7, 2009
Showing with 13 additions and 13 deletions.
  1. +11 −11 lib/rails_sequel/rails_sequel.rb
  2. +2 −2 lib/rails_sequel/sequel_ext.rb
@@ -1,5 +1,5 @@
module RailsSequel
-
+
# Connects to database using constructed Database Connection URI
def self.connect
connection = Sequel.connect(options = self.prepare_options)
@@ -8,47 +8,47 @@ def self.connect
end
connection
end
-
+
# Returns loaded database.yml configuration for current environment
def self.config
@config ||= YAML::load(ERB.new(IO.read(File.join(Rails.root, "config", "database.yml"))).result)[Rails.env].with_indifferent_access
end
-
+
# Resets config
def self.reset_config!
@config = nil
end
-
+
# Constructs Database Connection URI
def self.prepare_options
options = {}
# Use SQLite by default
options[:adapter] = config[:adapter] || "sqlite"
-
+
# Use localhost as default host
options[:host] = config[:host] || config[:hostname] || "localhost"
-
+
# Default user is an empty string. Both username and user keys are supported.
options[:user] = config[:username] || config[:user] || ""
options[:password] = config[:password] || ""
-
+
# Both encoding and charset options are supported, default is utf8
options[:encoding] = config[:encoding] || config[:charset] || "utf8"
-
+
# Default database is hey_dude_configure_your_database
options[:database] = config[:database] || "hey_dude_configure_your_database"
-
+
# MSSQL support
[:db_type, :socket, :charset, :encoding].each do |var|
options[var] = config[var] if config[var]
end
-
+
# JDBC support
[:url, :uri].each do |var|
options[var] = config[var] if config[var]
end
-
+
options[:loggers] = [Rails.logger]
options
end
@@ -1,10 +1,10 @@
class Sequel::Model
-
+
# Allows Rails resource path helpers to work correctly
def to_param
pk.to_s
end
-
+
# Make new? play nice with Rails
def new_record?
new?

0 comments on commit db0ed7f

Please sign in to comment.