lib/data_mapper/database.rb in datamapper-0.2.0 vs lib/data_mapper/database.rb in datamapper-0.2.1
- old
+ new
@@ -85,11 +85,10 @@
#
# end # :second_database
class Database
@databases = {}
- @context = []
# Allows you to access any of the named databases you have already setup.
#
# default_db = DataMapper::Database[:default]
# second_db = DataMapper::Database[:second_database]
@@ -99,11 +98,11 @@
# Returns the array of Database sessions currently being used
#
# This is what gives us thread safety, boys and girls
def self.context
- @context
+ Thread::current[:context] || Thread::current[:context] = []
end
# Setup creates a database and sets all of your properties for that database.
# Setup looks for either a hash of options passed in to the database or a symbolized name
# for your database, as well as it's hash of parameters
@@ -155,15 +154,14 @@
end
# Creates a new database object with the name you specify, and a default set of options.
#
# The default options are as follows:
- # {:single_threaded => true, :host => 'localhost', :database => nil, :username => 'root', :password => '', :adapter = nil }
+ # { :host => 'localhost', :database => nil, :username => 'root', :password => '', :adapter = nil }
def initialize(name)
@name = name
- @single_threaded = true
@adapter = nil
@host = 'localhost'
@database = nil
@schema_search_path = nil
@username = 'root'
@@ -173,18 +171,10 @@
@log_level = Logger::WARN
@log_stream = nil
end
attr_reader :name, :adapter
- attr_writer :single_threaded
attr_accessor :host, :database, :schema_search_path, :username, :password, :log_stream, :log_level, :index_path, :socket
-
- # Returns true or false
- #
- # NOTE: single_threaded is true unless explicitly set to false.
- def single_threaded?
- @single_threaded
- end
# Allows us to set the adapter for this database object. It can only be set once, and expects two types of values.
#
# You may pass in either a class inheriting from DataMapper::Adapters::AbstractAdapter
# or pass in a string indicating the type of adapter you would like to use.
\ No newline at end of file