Class: NcsNavigator::Mdes::Differences::Entry
- Inherits:
-
Object
- Object
- NcsNavigator::Mdes::Differences::Entry
- Extended by:
- Forwardable
- Defined in:
- lib/ncs_navigator/mdes/differences/entry.rb
Overview
Captures the differences between two instances of one of the elements that makes up a specification. I.e., TransmissionTable, Variable, VariableType, or CodeListEntry.
Instance Attribute Summary collapse
-
#attribute_differences ⇒ Hash<Symbol, Object>
Return the differences for each attribute.
Class Method Summary collapse
-
.compute(o1, o2, attribute_criteria, diff_options) ⇒ Entry?
The differences between o1 and o2 according to the criteria, or nil if there are no differences.
Instance Attribute Details
#attribute_differences ⇒ Hash<Symbol, Object>
Return the differences for each attribute. Each key is the name of the attribute and each value is an object describing the difference. It might be a Value diff, a Collection diff, or another NcsNavigator::Mdes::Differences::Entry diff depending on the kind of attribute.
42 43 44 |
# File 'lib/ncs_navigator/mdes/differences/entry.rb', line 42 def attribute_differences @attribute_differences ||= {} end |
Class Method Details
.compute(o1, o2, attribute_criteria, diff_options) ⇒ Entry?
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ncs_navigator/mdes/differences/entry.rb', line 17 def self.compute(o1, o2, attribute_criteria, ) differences = attribute_criteria.each_with_object({}) do |(diff_attribute, criterion), diffs| o_attribute = (criterion.respond_to?(:attribute) && criterion.attribute) || diff_attribute d = criterion.apply(o1.send(o_attribute), o2.send(o_attribute), ) diffs[diff_attribute] = d if d end if differences.empty? nil else Entry.new.tap { |e| e.attribute_differences = differences } end end |