diff options
author | gbuesing <gbuesing@gmail.com> | 2008-04-20 21:57:56 -0500 |
---|---|---|
committer | gbuesing <gbuesing@gmail.com> | 2008-04-20 21:57:56 -0500 |
commit | 6ef4239f8bd4d4ea7a5bc7f2cdaf14f87e6eb9a1 (patch) | |
tree | 54a76b1698a9012d5b37c3ee13d258c9a03beaa6 | |
parent | 32b82e4c6f5523cdf5ee78c3022c50b46e018351 (diff) | |
parent | 1d18651ea36e2ba274b6c2e0fd4edd425e028589 (diff) | |
download | rails-6ef4239f8bd4d4ea7a5bc7f2cdaf14f87e6eb9a1.tar.gz rails-6ef4239f8bd4d4ea7a5bc7f2cdaf14f87e6eb9a1.tar.bz2 rails-6ef4239f8bd4d4ea7a5bc7f2cdaf14f87e6eb9a1.zip |
Merge branch 'master' of git@github.com:rails/rails
9 files changed, 40 insertions, 71 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 9c72fd945a..6555560bdd 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Remove ActionController::Base#view_controller_internals flag. [Pratik] + * Add conditional options to caches_page method. [Paul Horsfall] * Move missing template logic to ActionView. [Pratik] diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index c0f3122fbf..1aa027f9d7 100755 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -253,16 +253,11 @@ module ActionController #:nodoc: DEFAULT_RENDER_STATUS_CODE = "200 OK" include StatusCodes - - # Determines whether the view has access to controller internals @request, @response, @session, and @template. - # By default, it does. - @@view_controller_internals = true - cattr_accessor :view_controller_internals - - # Protected instance variable cache - @@protected_variables_cache = nil - cattr_accessor :protected_variables_cache - + + # Controller specific instance variables which will not be accessible inside views. + @@protected_view_variables = %w(@assigns @performed_redirect @performed_render @variables_added @request_origin @url @parent_controller + @action_name @before_filter_chain_aborted @action_cache_path) + # Prepends all the URL-generating helpers from AssetHelper. This makes it possible to easily move javascripts, stylesheets, # and images to a dedicated asset server away from the main web server. Example: # ActionController::Base.asset_host = "http://assets.example.com" @@ -1194,7 +1189,6 @@ module ActionController #:nodoc: def add_variables_to_assigns unless @variables_added add_instance_variables_to_assigns - add_class_variables_to_assigns if view_controller_internals @variables_added = true end end @@ -1208,30 +1202,11 @@ module ActionController #:nodoc: end def add_instance_variables_to_assigns - @@protected_variables_cache ||= Set.new(protected_instance_variables) - instance_variable_names.each do |var| - next if @@protected_variables_cache.include?(var) + (instance_variable_names - @@protected_view_variables).each do |var| @assigns[var[1..-1]] = instance_variable_get(var) end end - def add_class_variables_to_assigns - %w(view_paths logger).each do |cvar| - @assigns[cvar] = self.send(cvar) - end - end - - def protected_instance_variables - if view_controller_internals - %w(@assigns @performed_redirect @performed_render) - else - %w(@assigns @performed_redirect @performed_render - @_request @request @_response @response @_params @params - @_session @session @_cookies @cookies - @template @request_origin @parent_controller) - end - end - def request_origin # this *needs* to be cached! # otherwise you'd get different results if calling it more than once diff --git a/actionpack/lib/action_controller/caching/actions.rb b/actionpack/lib/action_controller/caching/actions.rb index 4410e47eb3..7b0551c664 100644 --- a/actionpack/lib/action_controller/caching/actions.rb +++ b/actionpack/lib/action_controller/caching/actions.rb @@ -41,7 +41,6 @@ module ActionController #:nodoc: base.extend(ClassMethods) base.class_eval do attr_accessor :rendered_action_cache, :action_cache_path - alias_method_chain :protected_instance_variables, :action_caching end end @@ -55,10 +54,6 @@ module ActionController #:nodoc: end protected - def protected_instance_variables_with_action_caching - protected_instance_variables_without_action_caching + %w(@action_cache_path) - end - def expire_action(options = {}) return unless cache_configured? diff --git a/actionpack/test/controller/new_render_test.rb b/actionpack/test/controller/new_render_test.rb index 80cf09e5f3..9f9d861d32 100644 --- a/actionpack/test/controller/new_render_test.rb +++ b/actionpack/test/controller/new_render_test.rb @@ -529,26 +529,10 @@ class NewRenderTest < Test::Unit::TestCase end def test_access_to_request_in_view - view_internals_old_value = ActionController::Base.view_controller_internals - - ActionController::Base.view_controller_internals = false - ActionController::Base.protected_variables_cache = nil - - get :hello_world - assert !assigns.include?('_request'), '_request should not be in assigns' - assert !assigns.include?('request'), 'request should not be in assigns' - - ActionController::Base.view_controller_internals = true - ActionController::Base.protected_variables_cache = nil - get :hello_world assert !assigns.include?('request'), 'request should not be in assigns' assert_kind_of ActionController::AbstractRequest, assigns['_request'] assert_kind_of ActionController::AbstractRequest, @response.template.request - - ensure - ActionController::Base.view_controller_internals = view_internals_old_value - ActionController::Base.protected_variables_cache = nil end def test_render_xml diff --git a/activesupport/lib/active_support/core_ext/date_time/conversions.rb b/activesupport/lib/active_support/core_ext/date_time/conversions.rb index aa9caf1774..c0175a5f28 100644 --- a/activesupport/lib/active_support/core_ext/date_time/conversions.rb +++ b/activesupport/lib/active_support/core_ext/date_time/conversions.rb @@ -3,17 +3,22 @@ module ActiveSupport #:nodoc: module DateTime #:nodoc: # Converting datetimes to formatted strings, dates, and times. module Conversions - def self.included(base) #:nodoc: + def self.append_features(base) #:nodoc: base.class_eval do - alias_method :to_default_s, :to_s if instance_methods.include?(:to_s) - alias_method :to_s, :to_formatted_s alias_method :default_inspect, :inspect - alias_method :inspect, :readable_inspect + alias_method :to_default_s, :to_s unless (instance_methods(false) & [:to_s, 'to_s']).empty? # Ruby 1.9 has DateTime#to_time which internally relies on Time. We define our own #to_time which allows # DateTimes outside the range of what can be created with Time. remove_method :to_time if instance_methods.include?(:to_time) end + + super + + base.class_eval do + alias_method :to_s, :to_formatted_s + alias_method :inspect, :readable_inspect + end end # Convert to a formatted string. See Time::DATE_FORMATS for predefined formats. diff --git a/activesupport/lib/active_support/core_ext/enumerable.rb b/activesupport/lib/active_support/core_ext/enumerable.rb index 1b96eb166a..8f111e29fc 100644 --- a/activesupport/lib/active_support/core_ext/enumerable.rb +++ b/activesupport/lib/active_support/core_ext/enumerable.rb @@ -1,4 +1,7 @@ module Enumerable + # Ruby 1.8.7 introduces group_by, but the result isn't ordered. Override it. + remove_method(:group_by) if [].respond_to?(:group_by) && RUBY_VERSION < '1.9' + # Collect an enumerable into sets, grouped by the result of a block. Useful, # for example, for grouping records by date. # @@ -19,7 +22,7 @@ module Enumerable (grouped[yield(element)] ||= []) << element grouped end - end if RUBY_VERSION < '1.9' + end unless [].respond_to?(:group_by) # Calculates a sum from the elements. Examples: # diff --git a/activesupport/lib/active_support/core_ext/string.rb b/activesupport/lib/active_support/core_ext/string.rb index a83474f278..25386af70a 100644 --- a/activesupport/lib/active_support/core_ext/string.rb +++ b/activesupport/lib/active_support/core_ext/string.rb @@ -2,7 +2,7 @@ require 'active_support/core_ext/string/inflections' require 'active_support/core_ext/string/conversions' require 'active_support/core_ext/string/access' require 'active_support/core_ext/string/starts_ends_with' -require 'active_support/core_ext/string/iterators' unless 'test'.respond_to?(:each_char) +require 'active_support/core_ext/string/iterators' require 'active_support/core_ext/string/unicode' require 'active_support/core_ext/string/xchar' require 'active_support/core_ext/string/filters' @@ -12,14 +12,7 @@ class String #:nodoc: include ActiveSupport::CoreExtensions::String::Conversions include ActiveSupport::CoreExtensions::String::Filters include ActiveSupport::CoreExtensions::String::Inflections - if RUBY_VERSION < '1.9' - include ActiveSupport::CoreExtensions::String::StartsEndsWith - else - alias starts_with? start_with? - alias ends_with? end_with? - end - if defined? ActiveSupport::CoreExtensions::String::Iterators - include ActiveSupport::CoreExtensions::String::Iterators - end + include ActiveSupport::CoreExtensions::String::StartsEndsWith + include ActiveSupport::CoreExtensions::String::Iterators include ActiveSupport::CoreExtensions::String::Unicode end diff --git a/activesupport/lib/active_support/core_ext/string/iterators.rb b/activesupport/lib/active_support/core_ext/string/iterators.rb index 73114d9d5f..66a08a5cd0 100644 --- a/activesupport/lib/active_support/core_ext/string/iterators.rb +++ b/activesupport/lib/active_support/core_ext/string/iterators.rb @@ -5,6 +5,10 @@ module ActiveSupport #:nodoc: module String #:nodoc: # Custom string iterators module Iterators + def self.append_features(base) + super unless '1.9'.respond_to?(:each_char) + end + # Yields a single-character string for each character in the string. # When $KCODE = 'UTF8', multi-byte characters are yielded appropriately. def each_char diff --git a/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb b/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb index 3960669798..09f9a188b5 100644 --- a/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb +++ b/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb @@ -3,10 +3,18 @@ module ActiveSupport #:nodoc: module String #:nodoc: # Additional string tests. module StartsEndsWith - def self.included(base) - base.class_eval do - alias_method :start_with?, :starts_with? - alias_method :end_with?, :ends_with? + def self.append_features(base) + if '1.8.7 and up'.respond_to?(:start_with?) + base.class_eval do + alias_method :starts_with?, :start_with? + alias_method :ends_with?, :end_with? + end + else + super + base.class_eval do + alias_method :start_with?, :starts_with? + alias_method :end_with?, :ends_with? + end end end |