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

Changeset 8947

Show
Ignore:
Timestamp:
02/29/08 04:36:54 (4 months ago)
Author:
nzkoz
Message:

2-0-stable: Revert [8866]

Files:

Legend:

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

    r8866 r8947  
    11*SVN* 
    2  
    3 * Improve associations performance by avoiding named block arguments.  #11109 [adymo] 
    42 
    53* 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

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

    r8866 r8947  
    7979      end 
    8080 
    81       def to_xml(options={}, &block) 
    82         if load_target 
    83           @target.to_xml(options, &block) 
    84         end 
    85       end 
    86  
    8781      protected 
    8882        def dependent? 
     
    127121 
    128122      private 
    129         def method_missing(method, *args
     123        def method_missing(method, *args, &block
    130124          if load_target 
    131             @target.send(method, *args)  { |*block_args| yield(*block_args) if block_given? } 
     125            @target.send(method, *args, &block) 
    132126          end 
    133127        end 
  • branches/2-0-stable/activerecord/lib/active_record/associations/has_many_through_association.rb

    r8866 r8947  
    114114 
    115115      # Calculate sum using SQL, not Enumerable 
    116       def sum(*args
    117         calculate(:sum, *args) { |*block_args| yield(*block_args) if block_given? } 
     116      def sum(*args, &block
     117        calculate(:sum, *args, &block) 
    118118      end 
    119119       
     
    129129 
    130130      protected 
    131         def method_missing(method, *args
     131        def method_missing(method, *args, &block
    132132          if @target.respond_to?(method) || (!@reflection.klass.respond_to?(method) && Class.respond_to?(method)) 
    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             } 
     133            super 
     134          else 
     135            @reflection.klass.send(:with_scope, construct_scope) { @reflection.klass.send(method, *args, &block) } 
    138136          end 
    139137        end