diff options
author | Xavier Noria <fxn@hashref.com> | 2010-07-26 18:57:02 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-07-26 18:57:02 +0200 |
commit | b31c0ae306cf4357304fd7fe8130480f336590f9 (patch) | |
tree | d28f1c4611da7a9edd5d2ec56ddd03752efbc33e /activesupport/lib | |
parent | 79f9fcd70d9c15f63f62fb04a46996ae29769937 (diff) | |
parent | c819c131f2d08a8c9089a6ef0dcadcf912e2538c (diff) | |
download | rails-b31c0ae306cf4357304fd7fe8130480f336590f9.tar.gz rails-b31c0ae306cf4357304fd7fe8130480f336590f9.tar.bz2 rails-b31c0ae306cf4357304fd7fe8130480f336590f9.zip |
Merge remote branch 'rails/master'
Diffstat (limited to 'activesupport/lib')
4 files changed, 25 insertions, 7 deletions
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index 9a6da38b1c..2b80bd214f 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -72,10 +72,6 @@ module ActiveSupport #:nodoc: methods.each { |m| class_eval "def #{m}(*) lock { super } end", __FILE__, __LINE__ } end - def get(key) - (val = assoc(key)) ? val[1] : [] - end - locked :concat, :each, :delete_if, :<< def new_constants_for(frames) @@ -85,7 +81,18 @@ module ActiveSupport #:nodoc: next unless mod.is_a?(Module) new_constants = mod.local_constant_names - prior_constants - get(mod_name).concat(new_constants) + + # If we are checking for constants under, say, :Object, nested under something + # else that is checking for constants also under :Object, make sure the + # parent knows that we have found, and taken care of, the constant. + # + # In particular, this means that since Kernel.require discards the constants + # it finds, parents will be notified that about those constants, and not + # consider them "new". As a result, they will not be added to the + # autoloaded_constants list. + each do |key, value| + value.concat(new_constants) if key == mod_name + end new_constants.each do |suffix| constants << ([mod_name, suffix] - ["Object"]).join("::") diff --git a/activesupport/lib/active_support/deprecation/proxy_wrappers.rb b/activesupport/lib/active_support/deprecation/proxy_wrappers.rb index dec56715be..b22d0a6941 100644 --- a/activesupport/lib/active_support/deprecation/proxy_wrappers.rb +++ b/activesupport/lib/active_support/deprecation/proxy_wrappers.rb @@ -3,6 +3,13 @@ require 'active_support/inflector' module ActiveSupport module Deprecation class DeprecationProxy #:nodoc: + def self.new(*args, &block) + object = args.first + + return object unless object + super + end + instance_methods.each { |m| undef_method m unless m =~ /^__|^object_id$/ } # Don't give a deprecation warning on inspect since test/unit and error diff --git a/activesupport/lib/active_support/notifications.rb b/activesupport/lib/active_support/notifications.rb index 886d7183eb..ca9f5ae1ac 100644 --- a/activesupport/lib/active_support/notifications.rb +++ b/activesupport/lib/active_support/notifications.rb @@ -45,7 +45,7 @@ module ActiveSupport class << self attr_writer :notifier - delegate :publish, :unsubscribe, :to => :notifier + delegate :publish, :to => :notifier def instrument(name, payload = {}) if @instrumenters[name] diff --git a/activesupport/lib/active_support/xml_mini.rb b/activesupport/lib/active_support/xml_mini.rb index 38e20d32da..352172027b 100644 --- a/activesupport/lib/active_support/xml_mini.rb +++ b/activesupport/lib/active_support/xml_mini.rb @@ -129,12 +129,16 @@ module ActiveSupport camelize = options.has_key?(:camelize) && options[:camelize] dasherize = !options.has_key?(:dasherize) || options[:dasherize] key = key.camelize if camelize - key = key.dasherize if dasherize + key = _dasherize(key) if dasherize key end protected + def _dasherize(key) + key.gsub(/(?!^[_]*)_(?![_]*$)/, '-') + end + # TODO: Add support for other encodings def _parse_binary(bin, entity) #:nodoc: case entity['encoding'] |