Sha256: 80cd1a8d863dcdd5af98d1859c32dcd1f6657611ebb4067ab89ff68517b5d9f0

Contents?: true

Size: 851 Bytes

Versions: 5

Compression:

Stored size: 851 Bytes

Contents

module Spinebox
  module Routes
    
    # Reset the routes
    def self.reset!
      @@app = nil
    end
    reset!
    
    # Draw the routes into a rack builder app
    def self.draw(&block)      
      @@app = Rack::Builder.app do
        
        # Reload on every request?
        if Spinebox.config.reload
          use Spinebox::Reloader
          use Rack::Reloader, 0
        end
        
        # Mapping from routes.rb
        instance_eval(&block)
      end
    end
    
    # The rack app
    def self.app
      @@app
    end
    
  end
  
  
  class << self
    
    # Returns a rack builder app with the drawn routes
    def app
      Routes.app || begin
        Spinebox.boot!
        Routes.app
      end
    end
    
    # Load the routes
    def load_routes!(routes = "./config/routes.rb")
      load routes
    end
    
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spinebox-0.0.15 lib/spinebox/routes.rb
spinebox-0.0.14 lib/spinebox/routes.rb
spinebox-0.0.13 lib/spinebox/routes.rb
spinebox-0.0.12 lib/spinebox/routes.rb
spinebox-0.0.11 lib/spinebox/routes.rb