diff options
author | Andrew White <pixeltrix@users.noreply.github.com> | 2016-11-14 19:59:43 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-14 19:59:43 +0000 |
commit | e491b2c06329afb3c989261a2865d2a93c8b84b8 (patch) | |
tree | dd44570d81335f60d655475c91ed3922c60a57d0 /activesupport/lib/active_support/core_ext/module/qualified_const.rb | |
parent | 3a82ad746ab479dd1addd9c723197fb9f927194b (diff) | |
parent | 0d7bd2031b4054fbdeab0a00dd58b1b08fb7fea6 (diff) | |
download | rails-e491b2c06329afb3c989261a2865d2a93c8b84b8.tar.gz rails-e491b2c06329afb3c989261a2865d2a93c8b84b8.tar.bz2 rails-e491b2c06329afb3c989261a2865d2a93c8b84b8.zip |
Merge pull request #27035 from rails/remove-active-support-deprecations
Remove Active Support deprecations
Diffstat (limited to 'activesupport/lib/active_support/core_ext/module/qualified_const.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/module/qualified_const.rb | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/activesupport/lib/active_support/core_ext/module/qualified_const.rb b/activesupport/lib/active_support/core_ext/module/qualified_const.rb deleted file mode 100644 index b9814e1dbe..0000000000 --- a/activesupport/lib/active_support/core_ext/module/qualified_const.rb +++ /dev/null @@ -1,70 +0,0 @@ -require "active_support/core_ext/string/inflections" - -#-- -# Allows code reuse in the methods below without polluting Module. -#++ - -module ActiveSupport - module QualifiedConstUtils - def self.raise_if_absolute(path) - raise NameError.new("wrong constant name #$&") if path =~ /\A::[^:]+/ - end - - def self.names(path) - path.split("::") - end - end -end - -## -# Extends the API for constants to be able to deal with qualified names. Arguments -# are assumed to be relative to the receiver. -# -#-- -# Qualified names are required to be relative because we are extending existing -# methods that expect constant names, ie, relative paths of length 1. For example, -# Object.const_get('::String') raises NameError and so does qualified_const_get. -#++ -class Module - def qualified_const_defined?(path, search_parents = true) - ActiveSupport::Deprecation.warn(<<-MESSAGE.squish) - Module#qualified_const_defined? is deprecated in favour of the builtin - Module#const_defined? and will be removed in Rails 5.1. - MESSAGE - - ActiveSupport::QualifiedConstUtils.raise_if_absolute(path) - - ActiveSupport::QualifiedConstUtils.names(path).inject(self) do |mod, name| - return unless mod.const_defined?(name, search_parents) - mod.const_get(name) - end - return true - end - - def qualified_const_get(path) - ActiveSupport::Deprecation.warn(<<-MESSAGE.squish) - Module#qualified_const_get is deprecated in favour of the builtin - Module#const_get and will be removed in Rails 5.1. - MESSAGE - - ActiveSupport::QualifiedConstUtils.raise_if_absolute(path) - - ActiveSupport::QualifiedConstUtils.names(path).inject(self) do |mod, name| - mod.const_get(name) - end - end - - def qualified_const_set(path, value) - ActiveSupport::Deprecation.warn(<<-MESSAGE.squish) - Module#qualified_const_set is deprecated in favour of the builtin - Module#const_set and will be removed in Rails 5.1. - MESSAGE - - ActiveSupport::QualifiedConstUtils.raise_if_absolute(path) - - const_name = path.demodulize - mod_name = path.deconstantize - mod = mod_name.empty? ? self : const_get(mod_name) - mod.const_set(const_name, value) - end -end |