class Ccp::Persistent::Versioned
Constants
- Storage
Attributes
ext[R]
kvs[R]
path[R]
Public Class Methods
new(dir, options = {})
click to toggle source
# File lib/ccp/persistent/versioned.rb, line 53 def initialize(dir, options = {}) @path = Pathname(dir) @kvs = options[:kvs] || :dir @ext = options[:ext] || :msgpack @storages = {} @path.mkpath end
Public Instance Methods
[](key)
click to toggle source
指定したストレージを返す。存在しなければ作成して返す
# File lib/ccp/persistent/versioned.rb, line 84 def [](key) storage = Storage.complete(key, path, @kvs, @ext) @storages[storage.to_s] ||= storage.create end
default()
click to toggle source
最新のストレージを返す。存在しなければ作成
# File lib/ccp/persistent/versioned.rb, line 74 def default latest || now end
inspect()
click to toggle source
# File lib/ccp/persistent/versioned.rb, line 89 def inspect "<Kvs::Versioned dir=#{path} kvs=#{@kvs} ext=#{@ext}>" end
latest()
click to toggle source
最新のストレージを返す。存在しなければnil
# File lib/ccp/persistent/versioned.rb, line 63 def latest storage = StorageScanner.scan(path).last storage ? self[storage] : nil end
latest!()
click to toggle source
最新のストレージを返す。存在しなければ例外
# File lib/ccp/persistent/versioned.rb, line 69 def latest! latest.must.exist { raise Ccp::Persistent::NotFound, "#{path}/*" } end
now()
click to toggle source
現在の時刻で新しいストレージを作成して返す
# File lib/ccp/persistent/versioned.rb, line 79 def now self[Time.now.to_i] end