module Sideload::Redis
Public Instance Methods
db()
click to toggle source
# File lib/sideload/redis.rb, line 9 def db @redis || db! end
db!(**config)
click to toggle source
# File lib/sideload/redis.rb, line 5 def db!(**config) @redis = ::Redis.new(**config) end
delete(full_path, target)
click to toggle source
# File lib/sideload/redis.rb, line 30 def delete(full_path, target) db.del(File.join(full_path, target)) end
read(path)
click to toggle source
# File lib/sideload/redis.rb, line 13 def read(path) return db.keys(path + "*").map do |key| [key.sub(path, ""), db.get(key)] end.to_h end
with(path, fname) { |path, fname| ... }
click to toggle source
# File lib/sideload/redis.rb, line 19 def with(path, fname) yield(path, fname) end
write(full_path, target, content) { |content| ... }
click to toggle source
# File lib/sideload/redis.rb, line 23 def write(full_path, target, content) if block_given? && !yield(content) raise ValidationError.new(self, "#{full_path}/#{target}", content) end db.set(File.join(full_path, target), content) end