Project

General

Profile

Actions

Feature #12267

closed

REXML Authoring constants are unwanted (or clash) when mixing into other namespaces

Added by DanRathbun (Dan Rathbun) over 8 years ago. Updated over 8 years ago.

Status:
Rejected
Target version:
-
[ruby-core:74881]

Description

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
Actions

Also available in: Atom PDF

Like0
Like0