lib/restruct/structure.rb in restruct-0.0.3 vs lib/restruct/structure.rb in restruct-0.1.0
- old
+ new
@@ -1,32 +1,36 @@
module Restruct
class Structure
- attr_reader :redis, :id
+ attr_reader :connection, :id
def initialize(options={})
- @redis = options[:redis] || Restruct.redis
+ @connection = options[:connection] || Restruct.connection
@id = Id.new options[:id] || Restruct.generate_id
end
def ==(object)
object.class == self.class &&
object.id == id &&
- object.redis == redis
+ object.connection == connection
end
alias_method :eql?, :==
def dump
- redis.call 'DUMP', id
+ connection.call 'DUMP', id
end
def restore(dump)
destroy
- redis.call 'RESTORE', id, 0, dump
+ connection.lazy 'RESTORE', id, 0, dump
end
def destroy
- redis.call 'DEL', id
+ connection.lazy 'DEL', id
+ end
+
+ def exists?
+ connection.call('EXISTS', id) == 1
end
end
end
\ No newline at end of file