lib/ohm.rb in ohm-2.0.0.alpha4 vs lib/ohm.rb in ohm-2.0.0.alpha5

- old
+ new

@@ -1242,17 +1242,20 @@ model.indices.each { |field| indices[field] = Array(send(field)) } uniques = {} model.uniques.each { |field| uniques[field] = send(field) } - _initialize_id if new? + features = { + "name" => model.name + } + if defined?(@id) + features["id"] = @id + end + response = script(LUA_SAVE, 0, - { "name" => model.name, - "id" => id, - "key" => key - }.to_msgpack, + features.to_msgpack, _sanitized_attributes.to_msgpack, indices.to_msgpack, uniques.to_msgpack ) @@ -1262,10 +1265,12 @@ else raise response end end + @id = response + return self end # Delete the model, including all the following keys: # @@ -1376,25 +1381,17 @@ else [key[:indices][att][val]] end end - def self.new_id - redis.call("INCR", key[:id]) - end - attr_writer :id def model self.class end def redis model.redis - end - - def _initialize_id - @id = model.new_id.to_s end def _sanitized_attributes result = []