example/config.ru in happy-0.1.0.pre22 vs example/config.ru in happy-0.1.0.pre23

- old
+ new

@@ -15,11 +15,11 @@ # your application, a new instance of your root controller class is # created, and its #route method is called. # # This method can be as simple or complex as you like. In this example # application, it wraps around a couple of annotated Happy examples. - # Usually, you'd use the #path? method to specify code to be executed if + # Usually, you'd use the #path method to specify code to be executed if # a certain path was requested; in this app, we're using a custom #example # method, that does the same thing but also records the example in a hash # so we can generated a "table of contents" in index.erb. def route @@ -36,32 +36,32 @@ content_type 'text/css' "/* I'm CSS! */\n\nbody { color: red }\n" end example 'Path parameters' do - path? 'hello' do - path? :name do + on 'hello' do + on :name do "Hello, #{params['name']}!" end end "Try #{link_to 'this', current_url('hello', 'hendrik')}!" end example 'Inline path parameters' do - path? 'hello-:name' do + on 'hello-:name' do "Hello, #{params['name']}!" end "Try #{link_to 'this', current_url('hello-hendrik')}!" end example 'Permissions' do # set up permissions ;-) can.dance! - path? 'dance' do + on 'dance' do if can.dance? "You can dance." else "You can not dance." end @@ -69,22 +69,22 @@ "Can you #{link_to 'dance', current_url('dance')}?" end example 'Layouts' do - path? 'with-layout' do + on 'with-layout' do layout 'layout.erb' - path? 'changed-my-mind' do + on 'changed-my-mind' do layout false "This should render without a layout." end - "This should render with a layout." + "This should render with a layout. But #{link_to 'this', current_url('changed-my-mind')} shouldn't!" end - "This should render without a layout." + "This should render without a layout. But #{link_to 'this', current_url('with-layout')} should." end example 'Invoking other controllers' do # creata new controller on the fly c = Happy.route do @@ -118,10 +118,10 @@ def example(name, path_name = nil, &blk) path_name ||= name.parameterize examples[name] = path_name # Create a path containing the example's code block - path?(path_name, &blk) + on path_name, &blk end end run TestApp