lib/redis/value.rb in redis-objects-0.2.3 vs lib/redis/value.rb in redis-objects-0.2.4
- old
+ new
@@ -7,13 +7,13 @@
include Redis::Helpers::CoreCommands
require 'redis/helpers/serialize'
include Redis::Helpers::Serialize
attr_reader :key, :options, :redis
- def initialize(key, redis=$redis, options={})
+ def initialize(key, *args)
@key = key
- @redis = redis
- @options = options
+ @options = args.last.is_a?(Hash) ? args.pop : {}
+ @redis = args.first || $redis
@redis.setnx(key, @options[:default]) if @options[:default]
end
def value=(val)
redis.set key, to_redis(val)
\ No newline at end of file