Class: Spree::Core::Engine

Inherits:
Rails::Engine
  • Object
show all
Defined in:
lib/spree/core/engine.rb,
lib/spree/core/routes.rb

Defined Under Namespace

Modules: DiagnosticsErrorSubscriber Classes: CustomFieldsEnvironment, Environment, OrderRoutingEnvironment, PricingEnvironment, PromoEnvironment, SpreeCalculators

Constant Summary collapse

DEPRECATED_ALIAS_FILES =

Deprecated constant aliases warn when their file loads. Leaving them out of eager loading keeps every boot quiet; they still load, and warn, the first time something references the old name.

%w[
  app/models/concerns/spree/user_methods.rb
  app/models/spree/asset.rb
  app/models/spree/classification.rb
  app/models/spree/promotion/rules/taxon.rb
  app/models/spree/promotion_rule_taxon.rb
  app/models/spree/prototype.rb
  app/models/spree/return_authorization_reason.rb
  app/models/spree/shipment.rb
  app/models/spree/shipping_method.rb
  app/models/spree/taxon.rb
  app/services/spree/checkout/add_store_credit.rb
  app/services/spree/checkout/remove_store_credit.rb
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.add_routes(&block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/spree/core/routes.rb', line 4

def self.add_routes(&block)
  @spree_routes ||= []

  # Anything that causes the application's routes to be reloaded will cause
  # this method to be called more than once (in some setups only in the
  # production env). Coupled with Rails' insistence that routes are not
  # drawn twice, that poses quite a serious problem.
  #
  # This is mainly why this whole file exists in the first place.
  #
  # Thus we need to make sure that the routes aren't drawn twice.
  @spree_routes << block unless @spree_routes.include?(block)
end

.append_routes(&block) ⇒ Object



18
19
20
21
22
# File 'lib/spree/core/routes.rb', line 18

def self.append_routes(&block)
  @append_routes ||= []
  # See comment in add_routes.
  @append_routes << block unless @append_routes.include?(block)
end

.draw_routes(&block) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/spree/core/routes.rb', line 24

def self.draw_routes(&block)
  @spree_routes ||= []
  @append_routes ||= []
  eval_block(block) if block_given?
  @spree_routes.each { |r| eval_block(&r) }
  @append_routes.each { |r| eval_block(&r) }
  # # Clear out routes so that they aren't drawn twice.
  @spree_routes = []
  @append_routes = []
end

Instance Method Details

#eval_block(&block) ⇒ Object



35
36
37
# File 'lib/spree/core/routes.rb', line 35

def eval_block(&block)
  Spree::Core::Engine.routes.send :eval_block, block
end