Sha256: b459590c2c30b185b74a7b4314f2fac0101b940504c5e2314316e54569b749a0

Contents?: true

Size: 1.5 KB

Versions: 11

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true

require 'solidus_support/legacy_event_compat/bus'
require 'solidus_support/legacy_event_compat/subscriber'

module SolidusSupport
  # Compatibility middleman for {Spree::Event} and {Spree::Bus}
  #
  # Solidus v3.2 changed to use [Omnes](https://github.com/nebulab/omnes) as the
  # backbone for event-driven behavior (see {Spree::Bus}) by default. Before
  # that, a custom adapter based on {ActiveSupport::Notifications} was used (see
  # {Spree::Event}. Both systems are still supported on v3.2.
  #
  # This module provides compatibility support so that extensions can easily
  # target both systems regardless of the underlying circumstances:
  #
  # - Solidus v3.2 with the new system.
  # - Solidus v3.2 with the legacy system.
  # - Solidus v2.9 to v3.1, when only {Spree::Event} existed.
  # - Possible future versions of Solidus, whether the legacy system is
  # eventually removed or not.
  module LegacyEventCompat
    # Returns whether the application is using the legacy event system
    #
    # @return [Boolean]
    def self.using_legacy?
      legacy_present? &&
        (legacy_alone? ||
         legacy_chosen?)
    end

    def self.legacy_present?
      defined?(Spree::Event)
    end
    private_class_method :legacy_present?

    def self.legacy_alone?
      !Spree::Config.respond_to?(:use_legacy_events)
    end
    private_class_method :legacy_alone?

    def self.legacy_chosen?
      Spree::Config.use_legacy_events
    end
    private_class_method :legacy_chosen?
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
solidus_support-0.14.1 lib/solidus_support/legacy_event_compat.rb
solidus_support-0.14.0 lib/solidus_support/legacy_event_compat.rb
solidus_support-0.13.0 lib/solidus_support/legacy_event_compat.rb
solidus_support-0.10.3 lib/solidus_support/legacy_event_compat.rb
solidus_support-0.10.2 lib/solidus_support/legacy_event_compat.rb
solidus_support-0.10.1 lib/solidus_support/legacy_event_compat.rb
solidus_support-0.10.0 lib/solidus_support/legacy_event_compat.rb
solidus_support-0.9.3 lib/solidus_support/legacy_event_compat.rb
solidus_support-0.9.2 lib/solidus_support/legacy_event_compat.rb
solidus_support-0.9.1 lib/solidus_support/legacy_event_compat.rb
solidus_support-0.9.0 lib/solidus_support/legacy_event_compat.rb