Sha256: fab421ff2a30b78619dd01de51fb3418b28656e959e9853451b0cf92f29c6e52

Contents?: true

Size: 767 Bytes

Versions: 47

Compression:

Stored size: 767 Bytes

Contents

# frozen_string_literal: true

module Spree
  module Preferences
    class PreferenceDifferentiator
      attr_reader :config_class

      def initialize(config_class)
        @config_class = config_class
      end

      def call(from:, to:)
        preferences_from = config_class.new.load_defaults(from)
        preferences_to = config_class.new.load_defaults(to)
        config_class.versioned_preferences.reduce({}) do |changes, pref_key|
          value_from = preferences_from[pref_key]
          value_to = preferences_to[pref_key]
          if value_from == value_to
            changes
          else
            changes.merge(
              pref_key => { from: value_from, to: value_to }
            )
          end
        end
      end
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
solidus_core-4.4.2 lib/spree/preferences/preference_differentiator.rb
solidus_core-4.4.1 lib/spree/preferences/preference_differentiator.rb
solidus_core-4.4.0 lib/spree/preferences/preference_differentiator.rb
solidus_core-4.3.4 lib/spree/preferences/preference_differentiator.rb
solidus_core-4.2.4 lib/spree/preferences/preference_differentiator.rb
solidus_core-4.1.5 lib/spree/preferences/preference_differentiator.rb
solidus_core-4.3.3 lib/spree/preferences/preference_differentiator.rb
solidus_core-4.3.2 lib/spree/preferences/preference_differentiator.rb
solidus_core-4.1.4 lib/spree/preferences/preference_differentiator.rb
solidus_core-4.3.1 lib/spree/preferences/preference_differentiator.rb
solidus_core-4.3.0 lib/spree/preferences/preference_differentiator.rb
solidus_core-4.2.3 lib/spree/preferences/preference_differentiator.rb
solidus_core-4.1.3 lib/spree/preferences/preference_differentiator.rb
solidus_core-4.0.4 lib/spree/preferences/preference_differentiator.rb
solidus_core-3.4.6 lib/spree/preferences/preference_differentiator.rb
solidus_core-4.0.3 lib/spree/preferences/preference_differentiator.rb
solidus_core-4.1.2 lib/spree/preferences/preference_differentiator.rb
solidus_core-4.2.2 lib/spree/preferences/preference_differentiator.rb
solidus_core-3.4.5 lib/spree/preferences/preference_differentiator.rb
solidus_core-4.2.1 lib/spree/preferences/preference_differentiator.rb