Sha256: 07daf21733907e45135ca97dfc02d990fb3e4c92bbb361ff65fe2a119f003957

Contents?: true

Size: 682 Bytes

Versions: 1

Compression:

Stored size: 682 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.new(&block).to_app
    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
        Routes.reset!
        Spinebox.load_config!
        Spinebox.load_routes!
        Routes.app
      end
    end
    
    # Load the routes
    def load_routes!(routes = "./config/routes.rb")
      require routes
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spinebox-0.0.1 lib/spinebox/routes.rb