Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

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  
    20882088      # The extent of a "deep" clone is application-specific and is therefore 
    20892089      # left to the application to implement according to its need. 
    20902090      def clone 
    2091         attrs = self.attributes_before_type_cast 
     2091        attrs = clone_attributes(:read_attribute_before_type_cast) 
    20922092        attrs.delete(self.class.primary_key) 
    20932093        record = self.class.new 
    20942094        record.send :instance_variable_set, '@attributes', attrs 
     
    22362236        end 
    22372237      end 
    22382238 
    2239       # Returns a hash of cloned attributes before typecasting and deserialization. 
     2239      # Returns a hash of attributes before typecasting and deserialization. 
    22402240      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 
    22422246      end 
    22432247 
    22442248      # Format attributes nicely for inspect.