Class: Crm::ArticleRevisionDiffRowComponent::DataValues
- Inherits:
-
Object
- Object
- Crm::ArticleRevisionDiffRowComponent::DataValues
- Defined in:
- app/components/crm/article_revision_diff_row_component/data_values.rb
Overview
Resolves stored Article revision data to stable keys and reviewer-facing labels.
Constant Summary collapse
- BOOLEAN_FIELDS =
Fields whose values are booleans and render as "Yes" / "No".
%i[sales support warranty_labor warranty_parts].freeze
Instance Method Summary collapse
-
#initialize(field:, current:, proposed:) ⇒ DataValues
constructor
A new instance of DataValues.
-
#to_a ⇒ Array<Hash{String => String}>
Resolves the current and proposed values into keyed hashes of labels.
Constructor Details
#initialize(field:, current:, proposed:) ⇒ DataValues
Returns a new instance of DataValues.
12 13 14 15 16 |
# File 'app/components/crm/article_revision_diff_row_component/data_values.rb', line 12 def initialize(field:, current:, proposed:) @field = field.to_sym @current = current @proposed = proposed end |
Instance Method Details
#to_a ⇒ Array<Hash{String => String}>
Resolves the current and proposed values into keyed hashes of labels.
20 21 22 23 24 25 26 27 28 29 |
# File 'app/components/crm/article_revision_diff_row_component/data_values.rb', line 20 def to_a case field when :product_line_ids then record_values(ProductLine) when :product_category_ids then record_values(ProductCategory) when :item_ids then record_values(Item) when :tags then [current, proposed].map { |values| Array(values).index_with(&:to_s) } when :content_links then content_link_values else scalar_values end end |