public
Rubygem
Description: Extras for DataMapper, including bridges to DataObjects::Migrations and Merb::DataMapper
Homepage: http://datamapper.org
Clone URL: git://github.com/sam/dm-more.git
Applied David Yeu's fix for private properties on dm-validations. Resolves #373.
Thu Jul 10 07:35:00 -0700 2008
commit  ae861dd819363f8c22a3f657d3fc8377209fa945
tree    695763afb20d886637e3be34730ad1de3a23935a
parent  f6a5af1e6e9f23bb5b7a2afe00d39d8cbdcf2f7f
...
97
98
99
100
101
102
 
103
104
105
...
97
98
99
 
 
 
100
101
102
103
0
@@ -97,9 +97,7 @@ module DataMapper
0
 
0
 
0
     def validation_property_value(name)
0
-      return self.instance_variable_get("@#{name}") if self.instance_variables.include?(name)
0
-      return self.send(name) if self.respond_to?(name)
0
-      nil
0
+      self.respond_to?(name, true) ? self.send(name) : nil
0
     end
0
 
0
     # Get the corresponding Resource property, if it exists.
...
336
337
338
 
 
 
 
 
 
 
 
 
 
 
 
 
339
...
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
0
@@ -336,4 +336,17 @@ describe DataMapper::Validate do
0
 
0
     invoice.all_valid?.should == true
0
   end
0
+
0
+  it "should retrieve private instance variables for validation" do
0
+    class Raft
0
+      include DataMapper::Resource
0
+      property :length, Integer, :accessor => :private
0
+
0
+      def initialize(length)
0
+        @length = length
0
+      end
0
+    end
0
+
0
+    Raft.new(10).validation_property_value("length").should == 10
0
+  end
0
 end

Comments