Class: Spree::Stores::FindDefault

Inherits:
Object
  • Object
show all
Defined in:
app/finders/spree/stores/find_default.rb

Instance Method Summary collapse

Constructor Details

#initialize(scope: nil, url: nil) ⇒ FindDefault

Returns a new instance of FindDefault.



4
5
6
# File 'app/finders/spree/stores/find_default.rb', line 4

def initialize(scope: nil, url: nil)
  @scope = scope || Spree::Store
end

Instance Method Details

#executeObject



8
9
10
11
12
13
14
# File 'app/finders/spree/stores/find_default.rb', line 8

def execute
  store = @scope.where(default: true).first || @scope.first
  return if store.nil?

  Spree::Current.store = store
  store
end