Class: Crm::ArticleRevisionDiffRowComponent::KeyedDiff
- Inherits:
-
Object
- Object
- Crm::ArticleRevisionDiffRowComponent::KeyedDiff
- Defined in:
- app/components/crm/article_revision_diff_row_component/keyed_diff.rb
Overview
Uses Hashdiff to classify stable-key Article data as added or removed.
Instance Method Summary collapse
-
#entries(side) ⇒ Array<Array(Object, Symbol)>
Returns each value for one side of the diff paired with its change state.
-
#initialize(current:, proposed:) ⇒ KeyedDiff
constructor
A new instance of KeyedDiff.
Constructor Details
#initialize(current:, proposed:) ⇒ KeyedDiff
Returns a new instance of KeyedDiff.
7 8 9 10 |
# File 'app/components/crm/article_revision_diff_row_component/keyed_diff.rb', line 7 def initialize(current:, proposed:) @current = normalize(current) @proposed = normalize(proposed) end |
Instance Method Details
#entries(side) ⇒ Array<Array(Object, Symbol)>
Returns each value for one side of the diff paired with its change state.
17 18 19 20 21 |
# File 'app/components/crm/article_revision_diff_row_component/keyed_diff.rb', line 17 def entries(side) values_for(side).map do |key, value| [value, states.fetch(side).fetch(key, :unchanged)] end end |