Class: Spree::Tracker

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/spree/tracker.rb

Class Method Summary collapse

Class Method Details

.current(store = nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/models/spree/tracker.rb', line 4

def self.current(store = nil)
  return if !store
  if store.is_a?(Spree::Store)
    Spree::Tracker.where(active: true, store_id: store).first
  else
    # TODO: Remove in 2.0
    ActiveSupport::Deprecation.warn <<-EOS.squish, caller
      Calling Spree::Tracker.current with a string is DEPRECATED. Instead
      pass it an instance of Spree::Store.
    EOS
    Spree::Tracker.where(active: true).joins(:store).where(
      "spree_stores.code = ? OR spree_stores.url LIKE ?",
      store, "%#{store}%"
    ).first
  end
end