lib/ohm.rb in ohm-0.1.0.rc1 vs lib/ohm.rb in ohm-0.1.0.rc2

- old
+ new

@@ -7,11 +7,10 @@ require File.join(File.dirname(__FILE__), "ohm", "compat-1.8.6") require File.join(File.dirname(__FILE__), "ohm", "key") require File.join(File.dirname(__FILE__), "ohm", "collection") module Ohm - VERSION = "0.1.0.rc1" # Provides access to the Redis database. This is shared accross all models and instances. def redis threaded[:redis] ||= connection(*options) end @@ -551,10 +550,11 @@ # event2 = Event.create day: "2009-09-09", author: "Benoit" # event3 = Event.create day: "2009-09-10", author: "Albert" # # assert_equal [event1], Event.find(author: "Albert", day: "2009-09-09") def self.find(hash) + raise ArgumentError, "You need to supply a hash with filters. If you want to find by ID, use #{self}[id] instead." unless hash.kind_of?(Hash) all.find(hash) end def self.encode(value) Base64.encode64(value.to_s).gsub("\n", "") @@ -693,10 +693,10 @@ self.class.key(id, *args) end def write unless attributes.empty? - attributes.each_with_index do |att, index| + attributes.each do |att| value = send(att).to_s if value.empty? db.hdel(key, att) else