Parent

Class Index [+]

Quicksearch

Merb::Router::Behavior::Proxy

Proxy catches any methods and proxies them to the current behavior. This allows building routes without constantly having to catching the yielded behavior object

:api: private

Public Class Methods

new() click to toggle source

:api: private

    # File lib/merb-core/dispatch/router/behavior.rb, line 21
21:         def initialize
22:           @behaviors = []
23:         end

Public Instance Methods

pop() click to toggle source

Removes the top-most behavior.

Notes

This occurs at the end of a nested scope (namespace, etc).

:api: private

    # File lib/merb-core/dispatch/router/behavior.rb, line 41
41:         def pop
42:           @behaviors.pop
43:         end
push(behavior) click to toggle source

Puts a behavior on the bottom of the stack.

Notes

The behaviors keep track of nested scopes.

:api: private

    # File lib/merb-core/dispatch/router/behavior.rb, line 31
31:         def push(behavior)
32:           @behaviors.push(behavior)
33:         end
redirect(url, opts = {}) click to toggle source

Generates a Rack redirection response.

Notes

Refer to Merb::Rack::Helpers.redirect for documentation.

:api: public

     # File lib/merb-core/dispatch/router/behavior.rb, line 139
139:         def redirect(url, opts = {})
140:           Merb::Rack::Helpers.redirect(url, opts)
141:         end
respond_to?(*args) click to toggle source

Tests whether the top-most behavior responds to the arguments.

Notes

Behaviors contain the actual functionality of the proxy.

:api: private

    # File lib/merb-core/dispatch/router/behavior.rb, line 51
51:         def respond_to?(*args)
52:           super || @behaviors.last.respond_to?(*args)
53:         end
url(name, *args) click to toggle source

There are three possible ways to use this method. First, if you have a named route, you can specify the route as the first parameter as a symbol and any paramters in a hash. Second, you can generate the default route by just passing the params hash, just passing the params hash. Finally, you can use the anonymous parameters. This allows you to specify the parameters to a named route in the order they appear in the router.

Parameters(Named Route)

name

The name of the route.

args

Parameters for the route generation.

Parameters(Default Route)

args

Parameters for the route generation. This route will use the default route.

Parameters(Anonymous Parameters)

name

The name of the route.

args

An array of anonymous parameters to generate the route with. These parameters are assigned to the route parameters in the order that they are passed.

Returns

String

The generated URL.

Examples

Named Route

Merb::Router.prepare do

  match("/articles/:title").to(:controller => :articles, :action => :show).name("articles")

end

url(:articles, :title => “new_article“)

Default Route

Merb::Router.prepare do

  default_routes

end

url(:controller => “articles”, :action => “new”)

Anonymous Paramters

Merb::Router.prepare do

  match("/articles/:year/:month/:title").to(:controller => :articles, :action => :show).name("articles")

end

url(:articles, 2008, 10, “test_article“)

:api: public

     # File lib/merb-core/dispatch/router/behavior.rb, line 128
128:         def url(name, *args)
129:           args << {}
130:           Merb::Router.url(name, *args)
131:         end

Private Instance Methods

method_missing(method, *args, &block) click to toggle source

Proxies the method calls to the behavior.

Notes

Please refer to: ruby-doc.org/core/classes/Kernel.html#M005951

:api: private

     # File lib/merb-core/dispatch/router/behavior.rb, line 152
152:         def method_missing(method, *args, &block)
153:           behavior = @behaviors.last
154:           
155:           if behavior.respond_to?(method)
156:             behavior.send(method, *args, &block)
157:           else
158:             super
159:           end
160:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.