Sha256: cf5ded21884f15cea6f4ca2e94658d2fce6269914ccad45674f3f4d5fc253130
Contents?: true
Size: 783 Bytes
Versions: 5
Compression:
Stored size: 783 Bytes
Contents
module CrossStub class UnsupportedStoreGetMode < Exception ; end module Stores class Base def initialize(truncate) truncate && dump(current, {}) end def get(mode = :current) case mode when :current then load(current) when :previous data = load(previous) delete(previous) data else raise UnsupportedStoreGetMode end end def set(data, mode = :current) case mode when :current then dump(current, data) when :previous then dump(previous, data) else raise UnsupportedStoreGetMode end end def clear set(get(:current), :previous) unless exists?(previous) delete(current) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems