public
Description: Fork of DataMapper 0.3 with patches to fix major show-stopping bugs
Clone URL: git://github.com/cardmagic/dm-works.git
Added a nil? method to HasManyAssociation::Set. Mimics AR, and gives a 
nicer syntax for end users

git-svn-id: http://datamapper.rubyforge.org/svn/trunk@642 
b9f95e1d-c398-435d-95f5-378b83d2b11d
chrononaut (author)
Fri Dec 28 02:46:59 -0800 2007
commit  4454d3dcba9d86569a5315aef1f9a03b1fdf48a5
tree    2551c2223234847f4ed70dc48f136189d651f297
parent  c7ccb47bd01fd8b508ae9a3647ae5b2be9138de9
...
138
139
140
141
142
 
 
 
 
 
...
138
139
140
 
141
142
143
144
145
146
0
@@ -138,4 +138,8 @@
0
 * Added private/protected properties
0
 * Remove HasOneAssociation, Make HasManyAssociation impersonate has_one relationships
0
 * Added #get method
0
-* Persistence module added, inheriting from DataMapper::Base no longer necessary
0
\ No newline at end of file
0
+* Persistence module added, inheriting from DataMapper::Base no longer necessary
0
+
0
+-- 0.3.0
0
+* HasManyAssociation::Set now has a nil? method, so we can do stuff like cage.animal.nil?
0
+
...
34
35
36
 
 
 
 
 
37
38
39
...
34
35
36
37
38
39
40
41
42
43
44
0
@@ -34,6 +34,11 @@ module DataMapper
0
         
0
         include Enumerable
0
         
0
+ # Returns true if the association has zero items
0
+ def nil?
0
+ @items.empty?
0
+ end
0
+
0
         def dirty?
0
           @items && @items.any? { |item| item.dirty? }
0
         end
...
27
28
29
 
30
31
32
...
27
28
29
30
31
32
33
0
@@ -27,6 +27,7 @@ describe DataMapper::Associations::HasManyAssociation do
0
     project = Project.new
0
     project.sections.should be_a_kind_of(Enumerable)
0
     project.sections.should be_empty
0
+ project.sections.should be_nil
0
   end
0
   
0
   it "should display correctly when inspected" do

Comments

    No one has commented yet.