public
Description: My assistance repo w/ minor tweaks (original @ http://assistance.rubyforge.org/svn/trunk)
Homepage: http://assistance.rubyforge.org
Clone URL: git://github.com/bricooke/assistance.git
Search Repo:
Fixed .validates {each ...} to work correctly.

git-svn-id: http://assistance.rubyforge.org/svn/trunk@30 
76a3b97d-4fa4-4887-8470-eb0d8fc1b0f2
ciconia (author)
Sat Feb 16 00:00:05 -0800 2008
commit  146b9e46e660db511acd1b95e28a7b4938bbec16
tree    338237de4a12527bc91c3fa457d58f2824227fdc
parent  38550c440e1bcaea189ac2aed7b06c17b4ca4e80
...
 
 
 
 
1
2
3
...
1
2
3
4
5
6
7
0
@@ -1,3 +1,7 @@
0
+=== 0.1.5 (2008-02-16)
0
+
0
+* Fixed .validates {each ...} to work correctly.
0
+
0
 === 0.1.4 (2008-02-08)
0
 
0
 * Added inheritance of validations.
...
83
84
85
86
87
 
 
88
89
90
...
83
84
85
 
 
86
87
88
89
90
0
@@ -83,8 +83,8 @@
0
     end
0
 
0
     # Delegates method calls to the receiver by calling receiver.validates_xxx.
0
- def method_missing(m, *args)
0
- @receiver.send(:"validates_#{m}", *args)
0
+ def method_missing(m, *args, &block)
0
+ @receiver.send(:"validates_#{m}", *args, &block)
0
     end
0
   end
0
   
...
339
340
341
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
0
@@ -339,4 +339,25 @@
0
     o.valid?.should be_true
0
   end
0
 end
0
+
0
+context ".validates with block" do
0
+ specify "should support calling .each" do
0
+ @c = Class.new do
0
+ attr_accessor :vvv
0
+
0
+ include Validation
0
+ validates do
0
+ each :vvv do |o, a, v|
0
+ o.errors[a] << "is less than zero" if v.to_i < 0
0
+ end
0
+ end
0
+ end
0
+
0
+ o = @c.new
0
+ o.vvv = 1
0
+ o.should be_valid
0
+ o.vvv = -1
0
+ o.should_not be_valid
0
+ end
0
+end

Comments

    No one has commented yet.