public
Description: response for lets you decorate your actions respond_to blocks
Homepage: http://blog.ardes.com/response_for
Clone URL: git://github.com/ianwhite/response_for.git
Click here to lend your support to: response_for and make a donation at www.pledgie.com !
Updated README with more notes about the API change
ianwhite (author)
Wed Sep 17 14:03:36 -0700 2008
commit  7700d0813bc19faf0e2d8834f3c83c29379b4988
tree    191bd2de0434fc6e18e9434c40b238493f61d0c1
parent  8ac908ade87b73d18340fccb10e607123806a879
...
4
5
6
7
8
9
10
11
12
13
14
15
 
16
17
 
 
 
 
 
 
18
19
20
...
45
46
47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
49
50
...
4
5
6
 
 
 
 
7
8
9
10
 
11
12
13
14
15
16
17
18
19
20
21
22
...
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
0
@@ -4,17 +4,19 @@ response_for (see Ardes::ResponseFor::ClassMethods) allows you to decorate the r
0
 
0
 == Current Version 0.2-stable
0
 
0
-Version 0.2-stable of response_for has BC-breaking API changes, has vastly simplified internals, and is supported only for Rails >= 2.1.x.
0
-
0
-Version 0.2.0 was released on Sept 14th 2008.
0
-
0
 As of version 0.2.0, response_for's functionality can be summed up in one sentence:
0
 
0
 "response_for allows you to specify default responses for any action (or before filter) that doesn't render or redirect"
0
 
0
-Actions typically do two things - interact with models, and provide a repsonse.  The above simple idea allows you to decouple these
0
+Actions typically do two things - interact with models, and render a response.  The above simple idea allows you to decouple these
0
 two functions (where appropriate), which means abstraction of common patterns becomes possible.
0
 
0
+NOTE: 0.2-stable has BC-breaking API changes, and is supported only for Rails >= 2.1.x.  Version 0.2.0 was released on Sept 14th 2008.
0
+You should use 0.1-stable in your existing projects until you have runs your specs and whatnot.
0
+
0
+If you want to know more about why I changed the API in 0.2 look at the bottom of this README
0
+
0
+
0
 === Example
0
 
0
   class FooController < ApplicationController
0
@@ -45,6 +47,26 @@ RSpec is used for testing, so the tests are in <tt>spec/</tt> rather than
0
 garlic (at http://github.com/ianwhite/garlic) is used for CI.  To run the CI suite have a look at
0
 garlic_example.rb
0
 
0
+=== Why change the API in 0.2?
0
+
0
+repsonse_for <= v0.1 intercepted respond_to calls to allow overriding of these by class level declarations.  This turns out to have some 
0
+headaches, such as:
0
+
0
+* If you have some bail-out code in before_filters which uses respond_to, then response_for tries to overwrite this.  This meant that I had
0
+  to write response_for to only kick in once before_filters had run.  This made for some funky smelling code.
0
+* Sometimes your bail out code runs after the before_filters, in a superclass action for example, or just as part of your action (perhaps in
0
+  another method).  The above hack doesn't work for this case (the before_filters have run).  The solution in this case was to use
0
+  respond_to_without_response_for in any bail out code.
0
+* Conceptually, overriding code declared in methods, with code declared at the class level, is weird.  Here's an example
0
+
0
+  class FooController < SuperclassController
0
+    response_for :index # override Superclass's index respond_to
0
+    
0
+    def index
0
+      respond_to  # one might expect this to override the above, as its declared later - but it wont!
0
+    end
0
+  end
0
+
0
 == Previous Versions: 0.1
0
 
0
 There is a branch for rails 2.0 users on this release.  If you are using rails 2.0, then you want the 0.1-stable-rails2.0 branch.  If you are

Comments