From e737efe455b933906c4563ec4b15853d07fe45a4 Mon Sep 17 00:00:00 2001 From: ldss-jm Date: Thu, 19 Oct 2023 10:38:36 -0400 Subject: [PATCH] Defer evaluating ac_change unless/until needed --- lib/marc_wrangler/record_comparer.rb | 13 +++++++------ lib/marc_wrangler/version.rb | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/marc_wrangler/record_comparer.rb b/lib/marc_wrangler/record_comparer.rb index 86dab0c..25daef8 100644 --- a/lib/marc_wrangler/record_comparer.rb +++ b/lib/marc_wrangler/record_comparer.rb @@ -7,11 +7,8 @@ def initialize(rec, ex_rec, spec) @changed = detect_change(comparable_in_fields, comparable_ex_fields) - output_static = @spec['incoming record output files'] && - @spec['incoming record output files']['STATIC'] != 'do not output' - return unless @changed || output_static - - @ac_change = detect_ac_change(ac_in_fields, ac_ex_fields) + @output_static = @spec['incoming record output files'] && + @spec['incoming record output files']['STATIC'] != 'do not output' end def static? @@ -31,7 +28,11 @@ def detect_change(in_fields, ex_fields) end def ac_change? - @ac_change + return @ac_change if @ac_change + + return unless @changed || @output_static + + @ac_change ||= detect_ac_change(ac_in_fields, ac_ex_fields) end def detect_ac_change(in_fields, ex_fields) diff --git a/lib/marc_wrangler/version.rb b/lib/marc_wrangler/version.rb index d988fb3..60587aa 100644 --- a/lib/marc_wrangler/version.rb +++ b/lib/marc_wrangler/version.rb @@ -1,3 +1,3 @@ module MarcWrangler - VERSION = '0.1.5.1'.freeze + VERSION = '0.1.6'.freeze end