From: kou@... Date: 2016-04-12T02:08:20+00:00 Subject: [ruby-core:74884] [Ruby trunk Feature#12267][Rejected] REXML Authoring constants are unwanted (or clash) when mixing into other namespaces Issue #12267 has been updated by Kouhei Sutou. Status changed from Open to Rejected Assignee set to Kouhei Sutou You should not include a module when your code may conflict with constants in the module. ---------------------------------------- Feature #12267: REXML Authoring constants are unwanted (or clash) when mixing into other namespaces https://bugs.ruby-lang.org/issues/12267#change-58011 * Author: Dan Rathbun * Status: Rejected * Priority: Normal * Assignee: Kouhei Sutou ---------------------------------------- The following file can be added, OR it's contents pasted into "rexml/rexml.rb". Basically it renames the authoring constants defined in "rexml/rexml.rb", with a "REXML_" prefix. But it only does so when REXML module is mixed into some other class or module namespace. ``` # -*- encoding: utf-8 -*- # frozen_string_literal: false # # "rexml_mixin.rb" : include() and prepend() control require "rexml/rexml.rb" module REXML ### # # When mixing the REXML module into other classes and modules, # RENAME the 6 constants declared in "rexml/rexml.rb", because they # will likely conflict with the "mixee"'s constants of same name. # ### def self::append_features(mod) [:COPYRIGHT,:DATE,:VERSION,:REVISION,:Copyright,:Version].each {|id| const_set( "REXML_#{id.to_s}", REXML.const_get(id) ) remove_const(id) } super(mod) end def self::prepend_features(mod) [:COPYRIGHT,:DATE,:VERSION,:REVISION,:Copyright,:Version].each {|id| const_set( "REXML_#{id.to_s}", REXML.const_get(id) ) remove_const(id) } super(mod) end ### Do not think these constants need renaming for extend_object(). end ``` -- https://bugs.ruby-lang.org/ Unsubscribe: