Sha256: 89f6a97dbce11c9b1b06847c9b8e24bf6b45000e5ca20423c725e1141eecc15d

Contents?: true

Size: 430 Bytes

Versions: 32

Compression:

Stored size: 430 Bytes

Contents

module Spree
  class Tracker < Spree::Base
    after_commit :clear_cache

    validates :analytics_id, presence: true, uniqueness: { allow_blank: true }

    def self.current
      tracker = Rails.cache.fetch("current_tracker") do
        where(active: true).first
      end
      tracker.analytics_id.present? ? tracker : nil if tracker
    end


    def clear_cache
      Rails.cache.delete("current_tracker")
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
spree_core-3.2.9 app/models/spree/tracker.rb
spree_core-3.1.14 app/models/spree/tracker.rb
spree_core-3.2.8 app/models/spree/tracker.rb
spree_core-3.1.13 app/models/spree/tracker.rb
spree_core-3.2.7 app/models/spree/tracker.rb
spree_core-3.1.12 app/models/spree/tracker.rb
spree_core-3.2.6 app/models/spree/tracker.rb
spree_core-3.1.11 app/models/spree/tracker.rb
spree_core-3.1.10 app/models/spree/tracker.rb
spree_core-3.2.5 app/models/spree/tracker.rb
spree_core-3.1.9 app/models/spree/tracker.rb
spree_core-3.2.4 app/models/spree/tracker.rb
spree_core-3.1.8 app/models/spree/tracker.rb
spree_core-3.1.7 app/models/spree/tracker.rb
spree_core-3.2.3 app/models/spree/tracker.rb
spree_core-3.2.2 app/models/spree/tracker.rb
spree_core-3.1.6 app/models/spree/tracker.rb
spree_core-3.1.5 app/models/spree/tracker.rb
spree_core-3.2.1 app/models/spree/tracker.rb
spree_core-3.2.0 app/models/spree/tracker.rb