Class: DiffResource::Comparer
- Inherits:
-
Object
- Object
- DiffResource::Comparer
- Defined in:
- lib/diff_resource/comparer.rb
Constant Summary collapse
- @@struct_diff =
Struct.new "Diff", :key, :value, :old, :status
Instance Attribute Summary collapse
-
#diffs ⇒ Object
readonly
Returns the value of attribute diffs.
Instance Method Summary collapse
-
#initialize(new_resources, old_resources) ⇒ Comparer
constructor
A new instance of Comparer.
Constructor Details
#initialize(new_resources, old_resources) ⇒ Comparer
Returns a new instance of Comparer.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/diff_resource/comparer.rb', line 6 def initialize new_resources, old_resources @diffs = new_resources.map do |new_resource| ret = nil old_resources.each do |old_resource| next if new_resource.key != old_resource.key status = (new_resource.value == old_resource.value) ? :completed : :modified ret = @@struct_diff.new(new_resource.key, new_resource.value, old_resource.value, status) break end next ret unless ret.nil? @@struct_diff.new(new_resource.key, new_resource.value, "", :new) end end |
Instance Attribute Details
#diffs ⇒ Object (readonly)
Returns the value of attribute diffs.
23 24 25 |
# File 'lib/diff_resource/comparer.rb', line 23 def diffs @diffs end |