Sha256: 1fdb0a582bba2a5041326d5296e49663e412125b41a0229fe30ee6f6f9161b6a

Contents?: true

Size: 530 Bytes

Versions: 5

Compression:

Stored size: 530 Bytes

Contents

class Redis
  module Helpers
    module Serialize
      include Marshal

      def to_redis(value)
        return value unless options[:marshal]
        case value
        when String, Fixnum, Bignum, Float
          value
        else
          dump(value)
        end
      end
    
      def from_redis(value)
        return value unless options[:marshal]
        case value
        when Array
          value.collect{|v| from_redis(v)}
        else
          restore(value) rescue value
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
redis-objects-0.4.1 lib/redis/helpers/serialize.rb
redis-objects-0.4.0 lib/redis/helpers/serialize.rb
redis-objects-0.3.2 lib/redis/helpers/serialize.rb
redis-objects-0.3.1 lib/redis/helpers/serialize.rb
redis-objects-0.3.0 lib/redis/helpers/serialize.rb