Class | Ramaze::App
In: | lib/ramaze/app.rb
Parent: | Object

App is the superclass for applications and acts as their prototype when it comes to configuration.

An application consists of options, a location, and a list of objects. The objects are usually {Ramaze::Controller}s.

The options are inherited, the basics are set in Ramaze.options, from there to Ramaze::App.options, and finally into every instance of App.

This allows to collect {Ramaze::Controller}s of your application into a common group that can easily be used in other applications, while retaining the original options.

Every instance of {App} is mapped in {AppMap}, which is the default location to call from Rack.

Additionally, every {App} can have custom locations for root/public/view/layout directories, which allows reuse beyond directory boundaries.

In contrast to Innate, where all Nodes share the same middleware, {App} also has a subset of middleware that handles serving static files, routes and rewrites.

To indicate that a {Ramaze::Controller} belongs to a specific application, you can pass a second argument to {Ramaze::Controller::map}

@example adding Controller to application

      class WikiController < Ramaze::Controller
        map '/', :wiki
      end

The App instance will be created for you and if you don‘t use any other applications in your code there is nothing else you have to do. Others can now come and simply reuse your code in their own applications.

There is some risk of name collisions if everybody calls their app `:wiki`, but given that you only use one foreign app of this kind might give less reason for concern.

If you still try to use two apps with the same name, you have to be careful, loading one first, renaming it, then loading the second one.

The naming of an App has no influence on any other aspects of dispatching or configuration.

### Methods

[] call find_or_create location= map new public_roots sync to to_app

### Included Modules

Innate::Optioned

### Constants

APP_LIST | = | {}

### Attributes

location | [R] |
name | [R] |
options | [R] |
url_map | [R] |

### Public Class methods

[](name)

Returns the application for the given name.

@author Michael Fellinger @param [String] name The name of the application. @return [Ramaze::App]

find_or_create(name, location = nil)

Finds or creates an application for the given name and URI.

@author Michael Fellinger @param [String] name The name of the application. @param [String] location The URI to which the app is mapped. @return [Ramaze::App]

new(name, location = nil)

Creates a new instance of the application and sets the name and location.

@author Michael Fellinger @since 30-06-2009 @param [String] name The name of the application. @param [String] location The location to which the application is mapped.

### Public Instance methods

call(env)

Allows the application to be called as a Rack middleware.

@author Michael Fellinger @since 30-06-2009 @param [Hash] env The environment hash.

location=(location)

Sets the location and syncs the application.

@author Michael Fellinger @since 30-06-2009

map(location, object)

Maps an object to the given URI.

@author Michael Fellinger @since 30-06-2009 @param [String] location The URI to map the object to. @param [Object] object The object (usually a controller) to map to the

     URI.

public_roots()

Returns an array containing all the public directories for each root directory.

@author Michael Fellinger @since 30-06-2009 @return [Array]

sync()

Syncs the instance of the current application with Ramaze::AppMap.

@author Michael Fellinger @since 30-06-2009

to(object)

Returns a URI to the given object.

@author Michael Fellinger @since 30-06-2009 @param [Object] object An object for which to generate the URI.

to_app()

Converts the application to a Rack compatible class.

@author Michael Fellinger @since 30-06-2009 @return [Rack::Cascade]

[Validate]