public
Description: Conditional checks on Rails filters
Clone URL: git://github.com/thoughtbot/when.git
updated docs

git-svn-id: https://svn.thoughtbot.com/plugins/when/trunk@348 
7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
jcarroll (author)
Thu Feb 14 18:05:40 -0800 2008
commit  d8487bb35e0f65b57174dd237e439c1ee6c4c937
tree    24963f486eba3c7a2d1910e0ec5c501f25dc548a
parent  f8630086e8b81116b1b4d7772fc44a6e1b32f0c7
0
...
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
 
123
124
125
...
94
95
96
 
 
 
 
97
98
99
100
 
 
 
 
 
 
 
 
 
 
101
102
103
104
105
106
 
 
107
108
109
110
0
@@ -94,32 +94,17 @@ before_filter :log_in!,
0
 What When does NOT support
0
 ==========================
0
 
0
-# ActiveRecord String callbacks
0
-before_create 'self.password = password.to_sha1',
0
- :unless => lambda {|user| user.password_confirmation.blank?}
0
-
0
 # ActiveRecord Class callbacks
0
 before_create PasswordEncryptor,
0
   :unless => lambda {|user| user.password_confirmation.blank?}
0
 
0
-# ActiveRecord Block callbacks
0
-before_create(:unless => lambda {|user| user.password_confirmation.blank?}) do |record|
0
- record.password = record.password.to_sha1
0
-end
0
-
0
-# ActionController Block filters
0
-before_filter(:unless => :logged_in?) do |controller|
0
- redirect_to new_session_path
0
-end
0
-
0
 # ActionController Class filters
0
 before_filter Authorizer,
0
   :unless => :logged_in?
0
 
0
 When will not work if your code contains any of these.
0
 
0
-In our experience we've never used any of these types of callbacks and filters. By using Symbols, i.e. methods,
0
-the resulting code is much more intention revealing. Class callbacks and filters we feel are most of the time overkill.
0
+In our experience we've never used class callbacks or filters and find them to be overkill.
0
 
0
 Installation
0
 ============
...
22
23
24
25
 
26
27
28
...
22
23
24
 
25
26
27
28
0
@@ -22,7 +22,7 @@ module When
0
                       filter.call(controller)
0
                     else
0
                       raise ActionController::ActionControllerError,
0
- 'Filters must be a symbol denoting the method to call evaluated or a block to be invoked.'
0
+ 'Filters must be a symbol denoting the method to call or a block to be invoked.'
0
                     end
0
                   end
0
                 end

Comments

    No one has commented yet.