class RackWebDAV::LockStore
Public Class Methods
add(lock)
click to toggle source
# File lib/rack-webdav/lock_store.rb, line 9 def add(lock) @locks_by_path[lock.path] = lock @locks_by_token[lock.token] = lock end
create()
click to toggle source
# File lib/rack-webdav/lock_store.rb, line 5 def create @locks_by_path = {} @locks_by_token = {} end
explicit_locks(path)
click to toggle source
# File lib/rack-webdav/lock_store.rb, line 31 def explicit_locks(path) @locks_by_path.map do |lpath, lock| lpath == path && lock.remaining_timeout > 0 ? lock : nil end.compact end
explicitly_locked?(path)
click to toggle source
# File lib/rack-webdav/lock_store.rb, line 43 def explicitly_locked?(path) self.explicit_locks(path).size > 0 end
find_by_path(path)
click to toggle source
# File lib/rack-webdav/lock_store.rb, line 19 def find_by_path(path) @locks_by_path.map do |lpath, lock| lpath == path && lock.remaining_timeout > 0 ? lock : nil end.compact.first end
find_by_token(token)
click to toggle source
# File lib/rack-webdav/lock_store.rb, line 25 def find_by_token(token) @locks_by_token.map do |ltoken, lock| ltoken == token && lock.remaining_timeout > 0 ? lock : nil end.compact.first end
generate(path, user, token)
click to toggle source
# File lib/rack-webdav/lock_store.rb, line 51 def generate(path, user, token) l = Lock.new(:path => path, :user => user, :token => token) l.store = self add(l) l end
implicit_locks(path)
click to toggle source
# File lib/rack-webdav/lock_store.rb, line 37 def implicit_locks(path) @locks_by_path.map do |lpath, lock| lpath =~ /^#{Regexp.escape(path)}/ && lock.remaining_timeout > 0 && lock.depth > 0 ? lock : nil end.compact end
implicitly_locked?(path)
click to toggle source
# File lib/rack-webdav/lock_store.rb, line 47 def implicitly_locked?(path) self.implicit_locks(path).size > 0 end
remove(lock)
click to toggle source
# File lib/rack-webdav/lock_store.rb, line 14 def remove(lock) @locks_by_path.delete(lock.path) @locks_by_token.delete(lock.token) end