Sha256: 6ff513a17814b5d5540aa3c1cbd09163f3f360361162b28a55d5b78eb3db788b
Contents?: true
Size: 754 Bytes
Versions: 2
Compression:
Stored size: 754 Bytes
Contents
# frozen_string_literal: true module ModelAuditor module Normalizers class ArrayDiff attr_reader :changes, :key def initialize(changes, key) @changes = changes @key = key end def normalize diff.map do |title, value| humanize(title, value) end.join(', ') end private def diff { 'Inserted' => inserted, 'Removed' => removed }.reject { |_key, value| value.empty? } end def inserted changes[key].last - changes[key].first end def removed changes[key].first - changes[key].last end def humanize(title, value) [title, ModelAuditor.normalize_value(value)].join(': ') end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
model_auditor-0.0.2 | lib/model_auditor/normalizers/array_diff.rb |
model_auditor-0.0.1 | lib/model_auditor/normalizers/array_diff.rb |