Ticket #11077: avoid_cloning.diff
| File avoid_cloning.diff, 1.2 kB (added by juanjo.bazan, 5 months ago) |
|---|
-
activerecord/lib/active_record/base.rb
old new 2088 2088 # The extent of a "deep" clone is application-specific and is therefore 2089 2089 # left to the application to implement according to its need. 2090 2090 def clone 2091 attrs = self.attributes_before_type_cast2091 attrs = clone_attributes(:read_attribute_before_type_cast) 2092 2092 attrs.delete(self.class.primary_key) 2093 2093 record = self.class.new 2094 2094 record.send :instance_variable_set, '@attributes', attrs … … 2236 2236 end 2237 2237 end 2238 2238 2239 # Returns a hash of clonedattributes before typecasting and deserialization.2239 # Returns a hash of attributes before typecasting and deserialization. 2240 2240 def attributes_before_type_cast 2241 clone_attributes :read_attribute_before_type_cast 2241 attrs = {} 2242 self.attribute_names.each do |name| 2243 attrs[name]=read_attribute_before_type_cast(name) 2244 end 2245 attrs 2242 2246 end 2243 2247 2244 2248 # Format attributes nicely for inspect.