Class: Database::TreeDiff

Inherits:
Object
  • Object
show all
Defined in:
lib/database/tree_diff.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(database, prune = []) ⇒ TreeDiff

Returns a new instance of TreeDiff.



8
9
10
11
12
13
# File 'lib/database/tree_diff.rb', line 8

def initialize(database, prune = [])
  @database = database
  @changes  = {}

  build_routing_table(prune)
end

Instance Attribute Details

#changesObject (readonly)

Returns the value of attribute changes.



6
7
8
# File 'lib/database/tree_diff.rb', line 6

def changes
  @changes
end

Instance Method Details

#compare_oids(a, b, prefix = Pathname.new("")) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/database/tree_diff.rb', line 15

def compare_oids(a, b, prefix = Pathname.new(""))
  return if a == b

  a_entries = a ? oid_to_tree(a).entries : {}
  b_entries = b ? oid_to_tree(b).entries : {}

  detect_deletions(a_entries, b_entries, prefix)
  detect_additions(a_entries, b_entries, prefix)
end