lib/ohm.rb in ohm-0.1.4 vs lib/ohm.rb in ohm-0.1.5
- old
+ new
@@ -1713,10 +1713,11 @@
# # definition:
# Post.connect(:port => 6380, :db => 2)
#
# @see file:README.html#connecting Ohm.connect options documentation.
def self.connect(options = {})
+ Ohm.threaded[self] = nil
@options = options
end
# @return [Ohm::Key] A key scoped to the model which uses this object's
# id.
@@ -1803,14 +1804,10 @@
# Provides access to the Redis database. This is shared accross all models and instances.
def self.db
return Ohm.redis unless defined?(@options)
- Redis.connect(@options)
- end
-
- def self.db=(connection)
- Ohm.threaded[self] = connection
+ Ohm.threaded[self] ||= Redis.connect(@options)
end
# Allows you to do key manipulations scoped solely to your class.
def self.key
Key.new(self, db)