class Relaxo::Changeset
Attributes
changes[R]
ref[R]
Public Class Methods
new(repository, tree)
click to toggle source
Calls superclass method
# File lib/relaxo/changeset.rb, line 25 def initialize(repository, tree) super @changes = {} @directories = {} end
Public Instance Methods
abort!()
click to toggle source
# File lib/relaxo/changeset.rb, line 90 def abort! throw :abort end
append(data, type = :blob)
click to toggle source
# File lib/relaxo/changeset.rb, line 49 def append(data, type = :blob) oid = @repository.write(data, type) return @repository.read(oid) end
changes?()
click to toggle source
# File lib/relaxo/changeset.rb, line 35 def changes? @changes.any? end
delete(path)
click to toggle source
# File lib/relaxo/changeset.rb, line 75 def delete(path) root, _, name = path.rpartition('/') entry = @changes[path] = { action: :remove, path: path, root: root, name: name, } fetch_directory(root).delete(entry) return entry end
read(path)
click to toggle source
Calls superclass method
# File lib/relaxo/changeset.rb, line 39 def read(path) if update = @changes[path] if update[:action] != :remove @repository.read(update[:oid]) end else super end end
write(path, object, mode = 0100644)
click to toggle source
# File lib/relaxo/changeset.rb, line 55 def write(path, object, mode = 0100644) root, _, name = path.rpartition('/') entry = @changes[path] = { action: :upsert, oid: object.oid, object: object, filemode: mode, path: path, root: root, name: name, } fetch_directory(root).insert(entry) return entry end
Also aliased as: []=
write_tree()
click to toggle source
# File lib/relaxo/changeset.rb, line 94 def write_tree @tree.update(@changes.values) end