lib/redis/base_object.rb in redis-objects-1.3.0 vs lib/redis/base_object.rb in redis-objects-1.3.1

- old
+ new

@@ -16,11 +16,13 @@ def set_expiration if !@options[:expiration].nil? redis.expire(@key, @options[:expiration]) if redis.ttl(@key) < 0 elsif !@options[:expireat].nil? - redis.expireat(@key, @options[:expireat].to_i) if redis.ttl(@key) < 0 + expireat = @options[:expireat] + at = expireat.respond_to?(:call) ? expireat.call.to_i : expireat.to_i + redis.expireat(@key, at) if redis.ttl(@key) < 0 end end def allow_expiration(&block) result = block.call @@ -38,8 +40,17 @@ to_hash end def to_hash { "key" => @key, "options" => @options, "value" => value } + end + + # Math ops - delegate to value method + %w(== < > <= >=).each do |m| + class_eval <<-EndOverload + def #{m}(what) + value #{m} what + end + EndOverload end end end