Class: Spree::Core::Engine
- Inherits:
-
Rails::Engine
- Object
- Rails::Engine
- Spree::Core::Engine
- Defined in:
- lib/spree/core/engine.rb,
lib/spree/core/routes.rb
Class Method Summary collapse
Class Method Details
.add_routes(&block) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# 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 # i.e. https://github.com/plataformatec/devise/blob/31971e69e6a1bcf6c7f01eaaa44f227c4af5d4d2/lib/devise/rails.rb#L14 # In the case of Devise, this *only* happens in the production env # This coupled with Rails 4's insistence that routes are not drawn twice, # 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. unless @spree_routes.include?(block) @spree_routes << block end end |
.append_routes(&block) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/spree/core/routes.rb', line 22 def self.append_routes(&block) @append_routes ||= [] # See comment in add_routes. unless @append_routes.include?(block) @append_routes << block end end |
.draw_routes(&block) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/spree/core/routes.rb', line 30 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 |