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

Changeset 8866

Show
Ignore:
Timestamp:
02/14/08 07:27:39 (7 months ago)
Author:
rick
Message:

apply [8865] to 2.0 stable

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2-0-stable/activerecord/CHANGELOG

    r8837 r8866  
    11*SVN* 
     2 
     3* Improve associations performance by avoiding named block arguments.  #11109 [adymo] 
    24 
    35* Ensure that modifying has_and_belongs_to_many actions clear the query cache.  Closes #10840 [john.andrews] 
  • branches/2-0-stable/activerecord/lib/active_record/associations/association_collection.rb

    r8049 r8866  
    4444 
    4545      # Calculate sum using SQL, not Enumerable 
    46       def sum(*args, &block
    47         calculate(:sum, *args, &block) 
     46      def sum(*args
     47        calculate(:sum, *args) { |*block_args| yield(*block_args) if block_given? } 
    4848      end 
    4949 
     
    122122      end 
    123123 
    124       def any?(&block) 
     124      def any? 
    125125        if block_given? 
    126           method_missing(:any?, &block) 
     126          method_missing(:any?) { |*block_args| yield(*block_args) if block_given? } 
    127127        else 
    128128          !empty? 
     
    158158 
    159159      protected 
    160         def method_missing(method, *args, &block
     160        def method_missing(method, *args
    161161          if @target.respond_to?(method) || (!@reflection.klass.respond_to?(method) && Class.respond_to?(method)) 
    162             super 
     162            super { |*block_args| yield(*block_args) if block_given? } 
    163163          else 
    164             @reflection.klass.send(:with_scope, construct_scope) { @reflection.klass.send(method, *args, &block) } 
     164            @reflection.klass.send(:with_scope, construct_scope) { 
     165                @reflection.klass.send(method, *args) { |*block_args| yield(*block_args) if block_given? } 
     166            } 
    165167          end 
    166168        end 
     
    188190      private 
    189191 
    190         def create_record(attrs, &block
     192        def create_record(attrs
    191193          ensure_owner_is_not_new 
    192194          record = @reflection.klass.send(:with_scope, :create => construct_scope[:create]) { @reflection.klass.new(attrs) } 
    193           add_record_to_target_with_callbacks(record, &block) 
    194         end 
    195  
    196         def build_record(attrs, &block
     195          add_record_to_target_with_callbacks(record) { |*block_args| yield(*block_args) if block_given? } 
     196        end 
     197 
     198        def build_record(attrs
    197199          record = @reflection.klass.new(attrs) 
    198           add_record_to_target_with_callbacks(record, &block) 
     200          add_record_to_target_with_callbacks(record) { |*block_args| yield(*block_args) if block_given? } 
    199201        end 
    200202 
  • branches/2-0-stable/activerecord/lib/active_record/associations/association_proxy.rb

    r8347 r8866  
    7979      end 
    8080 
     81      def to_xml(options={}, &block) 
     82        if load_target 
     83          @target.to_xml(options, &block) 
     84        end 
     85      end 
     86 
    8187      protected 
    8288        def dependent? 
     
    121127 
    122128      private 
    123         def method_missing(method, *args, &block
     129        def method_missing(method, *args
    124130          if load_target 
    125             @target.send(method, *args, &block) 
     131            @target.send(method, *args)  { |*block_args| yield(*block_args) if block_given? } 
    126132          end 
    127133        end 
  • branches/2-0-stable/activerecord/lib/active_record/associations/has_many_through_association.rb

    r8481 r8866  
    114114 
    115115      # Calculate sum using SQL, not Enumerable 
    116       def sum(*args, &block
    117         calculate(:sum, *args, &block) 
     116      def sum(*args
     117        calculate(:sum, *args) { |*block_args| yield(*block_args) if block_given? } 
    118118      end 
    119119       
     
    129129 
    130130      protected 
    131         def method_missing(method, *args, &block
     131        def method_missing(method, *args
    132132          if @target.respond_to?(method) || (!@reflection.klass.respond_to?(method) && Class.respond_to?(method)) 
    133             super 
    134           else 
    135             @reflection.klass.send(:with_scope, construct_scope) { @reflection.klass.send(method, *args, &block) } 
     133            super { |*block_args| yield(*block_args) if block_given? } 
     134          else 
     135            @reflection.klass.send(:with_scope, construct_scope) { 
     136                @reflection.klass.send(method, *args) { |*block_args| yield(*block_args) if block_given? } 
     137            } 
    136138          end 
    137139        end