From: danzoid61@... Date: 2016-04-11T20:07:41+00:00 Subject: [ruby-core:74881] [Ruby trunk Feature#12267] REXML Authoring constants are unwanted (or clash) when mixing into other namespaces Issue #12267 has been reported by Dan Rathbun. ---------------------------------------- Feature #12267: REXML Authoring constants are unwanted (or clash) when mixing into other namespaces https://bugs.ruby-lang.org/issues/12267 * Author: Dan Rathbun * Status: Open * Priority: Normal * Assignee: ---------------------------------------- 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: