Class: Delta
- Inherits:
-
Object
show all
- Defined in:
- lib/delta/base.rb,
lib/delta/identifier.rb,
lib/delta/set_operator.rb,
lib/delta/set_operator/enumerable.rb,
lib/delta/set_operator/active_record.rb
Defined Under Namespace
Classes: Identifier, SetOperator
Instance Method Summary
collapse
Constructor Details
#initialize(from:, to:, identifiers: nil, changes: []) ⇒ Delta
Returns a new instance of Delta.
2
3
4
5
6
7
8
9
|
# File 'lib/delta/base.rb', line 2
def initialize(from:, to:, identifiers: nil, changes: [])
self.set = SetOperator.adapt(
a: from,
b: to,
identifiers: identifiers,
changes: changes
)
end
|
Instance Method Details
#additions ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/delta/base.rb', line 11
def additions
Enumerator.new do |y|
set.b_minus_a.each do |b|
y.yield b
end
end
end
|
#deletions ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/delta/base.rb', line 27
def deletions
Enumerator.new do |y|
set.a_minus_b.each do |a|
y.yield a
end
end
end
|
#modifications ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/delta/base.rb', line 19
def modifications
Enumerator.new do |y|
set.intersection.each do |b|
y.yield b
end
end
end
|