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

Changeset 7128

Show
Ignore:
Timestamp:
06/26/07 20:45:41 (1 year ago)
Author:
david
Message:

Allow sweepers to be created solely for expiring after controller actions, not model changes [DHH] Added assigns method to ActionController::Caching::Sweeper to easily access instance variables on the controller [DHH]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r7126 r7128  
    11*SVN* 
     2 
     3* Allow sweepers to be created solely for expiring after controller actions, not model changes [DHH] 
     4 
     5* Added assigns method to ActionController::Caching::Sweeper to easily access instance variables on the controller [DHH] 
    26 
    37* Give the legacy X-POST_DATA_FORMAT header greater precedence during params parsing for backward compatibility.  [Jeremy Kemper] 
  • trunk/actionpack/lib/action_controller/caching.rb

    r6970 r7128  
    637637          end 
    638638 
     639          # Retrieve instance variables set in the controller. 
     640          def assigns(key) 
     641            controller.instance_variable_get("@#{key}") 
     642          end 
     643 
    639644        private 
    640645          def callback(timing) 
  • trunk/activerecord/lib/active_record/observer.rb

    r5211 r7128  
    141141      #   assert_equal [Person], PersonObserver.observed_class 
    142142      def observed_class 
    143         name.scan(/(.*)Observer/)[0][0].constantize 
     143        if observed_class_name = name.scan(/(.*)Observer/)[0] 
     144          observed_class_name[0].constantize 
     145        else 
     146          nil 
     147        end 
    144148      end 
    145149    end 
     
    164168    protected 
    165169      def observed_classes 
    166         Set.new([self.class.observed_class].flatten) 
     170        Set.new([self.class.observed_class].compact.flatten) 
    167171      end 
    168172 
    169173      def observed_subclasses 
    170         observed_classes.sum(&:subclasses) 
     174        observed_classes.collect(&:subclasses).flatten 
    171175      end 
    172176