module Persist::TSVAdapter
Constants
- MAX_CHAR
Attributes
Public Instance Methods
Source
# File lib/rbbt/persist/tsv/adapter.rb, line 213 def [](*args) self.read_lock do super(*args) #- TSV::ENTRY_KEYS.to_a end end
Calls superclass method
Source
# File lib/rbbt/persist/tsv/adapter.rb, line 219 def []=(*args) self.write_lock do super(*args) #- TSV::ENTRY_KEYS.to_a end end
Calls superclass method
Source
# File lib/rbbt/persist/tsv/adapter.rb, line 32 def close(*args) begin super(*args) @closed = true rescue NoMethodError end self end
Calls superclass method
Source
# File lib/rbbt/persist/tsv/adapter.rb, line 256 def collect res = [] each do |key, value| res << if block_given? yield key, value else [key, value] end end res end
Source
# File lib/rbbt/persist/tsv/adapter.rb, line 48 def delete(key) self.write_lock do out(key) end end
Source
# File lib/rbbt/persist/tsv/adapter.rb, line 250 def each(*args, &block) self.read_lock do super(*args, &block) end end
Calls superclass method
Source
# File lib/rbbt/persist/tsv/adapter.rb, line 238 def get_prefix(key) keys = prefix(key) select(:key => keys) end
Source
# File lib/rbbt/persist/tsv/adapter.rb, line 207 def include?(*args) self.read_lock do super(*args) #- TSV::ENTRY_KEYS.to_a end end
Calls superclass method
Source
# File lib/rbbt/persist/tsv/adapter.rb, line 225 def keys(*args) self.read_lock do super(*args) end end
Calls superclass method
Source
# File lib/rbbt/persist/tsv/adapter.rb, line 54 def lock return yield if @locked lock_filename = Persist.persistence_path(persistence_path, {:dir => TSV.lock_dir}) Misc.lock(lock_filename) do begin @locked = true yield ensure @locked = false end end end
Source
# File lib/rbbt/persist/tsv/adapter.rb, line 67 def lock_and_close lock do begin yield ensure close end end end
Source
# File lib/rbbt/persist/tsv/adapter.rb, line 191 def merge!(hash) hash.each do |key,values| self[key] = values end end
Source
# File lib/rbbt/persist/tsv/adapter.rb, line 232 def prefix(key) self.read_lock do range(key, 1, key + MAX_CHAR, 1) end end
Source
# File lib/rbbt/persist/tsv/adapter.rb, line 197 def range(*args) begin self.read_lock do super(*args) end rescue [] end end
Calls superclass method
Source
# File lib/rbbt/persist/tsv/adapter.rb, line 41 def read(*args) begin super(*args) rescue NoMethodError end end
Calls superclass method
Source
# File lib/rbbt/persist/tsv/adapter.rb, line 141 def read_and_close if read? || write? begin return yield ensure close unless @locked end end lock do read true if closed? || ! read? begin yield ensure close end end end
Source
# File lib/rbbt/persist/tsv/adapter.rb, line 160 def read_lock read if closed? if read? || write? return yield end lock do close read true begin yield end end end
Source
# File lib/rbbt/persist/tsv/adapter.rb, line 244 def size(*args) self.read_lock do super(*args) end end
Calls superclass method
Source
# File lib/rbbt/persist/tsv/adapter.rb, line 268 def values_at(*keys) self.read_lock do keys.collect do |k| self[k] end end end
Source
# File lib/rbbt/persist/tsv/adapter.rb, line 116 def with_read(&block) if read? || write? return yield else read_and_close &block end end
Source
# File lib/rbbt/persist/tsv/adapter.rb, line 124 def with_write(&block) if write? return yield else if self.read? self.write_and_read do return yield end else self.write_and_close do return yield end end end end
Source
# File lib/rbbt/persist/tsv/adapter.rb, line 24 def write(*args) begin super(*args) @writable = true rescue NoMethodError end end
Calls superclass method
Source
# File lib/rbbt/persist/tsv/adapter.rb, line 96 def write_and_close if write? begin return yield ensure close unless @locked end end lock do write(true) if closed? || ! write? res = begin yield ensure close end res end end
Source
# File lib/rbbt/persist/tsv/adapter.rb, line 77 def write_and_read if write? begin return yield ensure read end end lock do write(true) if closed? || !write? begin yield ensure read end end end
Source
# File lib/rbbt/persist/tsv/adapter.rb, line 175 def write_lock write if closed? if write? return yield end lock do close write true begin yield end end end