lib/redis/value.rb in redis-objects-0.3.2 vs lib/redis/value.rb in redis-objects-0.4.0
- old
+ new
@@ -1,20 +1,20 @@
+require File.dirname(__FILE__) + '/base_object'
+
class Redis
#
# Class representing a simple value. You can use standard Ruby operations on it.
#
- class Value
+ class Value < BaseObject
require 'redis/helpers/core_commands'
include Redis::Helpers::CoreCommands
require 'redis/helpers/serialize'
include Redis::Helpers::Serialize
attr_reader :key, :options, :redis
def initialize(key, *args)
- @key = key
- @options = args.last.is_a?(Hash) ? args.pop : {}
- @redis = args.first || $redis
+ super(key, *args)
@redis.setnx(key, @options[:default]) if @options[:default]
end
def value=(val)
redis.set key, to_redis(val)
@@ -30,6 +30,6 @@
alias_method :to_str, :to_s
def ==(x); value == x; end
def nil?; value.nil?; end
end
-end
\ No newline at end of file
+end