0
@@ -43,19 +43,20 @@ module Waves
0
# path %r{^/#{resource}/#{name}/?$} do |resource, name|
0
- # use( resource ) | controller { find( name ) } |
0
- # view { | instance | show( resource => instance ) }
0
+ # resource( resource ) do
0
+ # controller { find( name ) } | view { | instance | show( resource => instance ) }
0
# In this example, we take the same rule from above but invoke a controller and view method.
0
- # We use the +
use+ directive and the resource parameter to set the MVC instances we're going
0
+ # We use the +
resource+ directive and the resource parameter to set the MVC instances we're going
0
# to use. This is necessary to use the +controller+ or +view+ methods. Each of these take
0
# a block as arguments which are evaluated in the context of the instance. The +view+ method
0
# can further take an argument which is "piped" from the result of the controller block. This
0
# isn't required, but helps to clarify the request processing. Within a view block, a hash
0
- # may also be passed in, which is converted into instance variables for the view instance. In
0
- # this example, the +show+ method is assigned to an instance variable with the same name as
0
+ # may also be passed in to the view method, which is converted into instance variables for the
0
+ # view instance. In this example, the +show+ method is assigned to an instance variable with the
0
+ # same name as the resource type.
0
# So given the same URL as above - /person/john - what will happen is the +find+ method for
0
# the +Person+ controller will be invoked and the result passed to the +Person+ view's +show+
0
@@ -66,12 +67,12 @@ module Waves
0
# controller and view can thus be completely decoupled and become easier to reuse separately.
0
# url 'http://admin.foobar.com:/' do
0
- #
use( admin ) | view { console }
0
+ #
resource( :admin ) { view { console } }
0
# In this example, we are using the +url+ method to map a subdomain of +foobar.com+ to the
0
# console method of the Admin view. In this case, we did not need a controller method, so
0
- # we simply didn't call one.
0
+ # we simply didn't call one.
0
@@ -79,8 +80,7 @@ module Waves
0
# mapping module. Some rule sets come packaged with Waves, such as PrettyUrls (rules for
0
# matching resources using names instead of ids). The simplest way to define such modules for
0
# reuse is by defining the +included+ class method for the rules module, and then define
0
- # the rules using +module_eval+. This will likely be made simpler in a future release, but
0
- # see the PrettyUrls module for an example of how to do this.
0
+ # the rules using +module_eval+. See the PrettyUrls module for an example of how to do this.
0
# *Important:* Using pre-packaged mapping rules does not prevent you from adding to or
0
# overriding these rules. However, order does matter, so you should put your own rules
Comments
No one has commented yet.