lib/redis/value.rb in redis-objects-0.8.0 vs lib/redis/value.rb in redis-objects-0.9.0

- old
+ new

@@ -5,30 +5,28 @@ # Class representing a simple value. You can use standard Ruby operations on it. # class Value < BaseObject require 'redis/helpers/core_commands' include Redis::Helpers::CoreCommands - require 'redis/helpers/serialize' - include Redis::Helpers::Serialize attr_reader :key, :options def initialize(key, *args) super(key, *args) - redis.setnx(key, to_redis(@options[:default])) if @options[:default] + redis.setnx(key, marshal(@options[:default])) if @options[:default] end def value=(val) if val.nil? delete else - redis.set key, to_redis(val) + redis.set key, marshal(val) end end alias_method :set, :value= def value - from_redis redis.get(key) + unmarshal redis.get(key) end alias_method :get, :value def inspect "#<Redis::Value #{value.inspect}>" @@ -40,7 +38,9 @@ def to_json(*args); value.to_json *args end def method_missing(*args) self.value.send *args end + + expiration_filter :value= end end