Ticket #15 (closed enhancement: fixed)
Element#clone should be changed to support decendent classes
| Reported by: | gwright | Owned by: | ser |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.1.6 |
| Component: | DOM | Version: | 3.1.2 |
| Severity: | normal | Keywords: | |
| Cc: | Ruby version: | 1.8.2 | |
| Operating system: | MacOS |
Description
Element#clone is current defined as
Element.new self
This has limited usefulness when self is actually a descendent of Element. The descendent class could of course also redefine clone but if Element#clone was defined as:
self.class.new self
Then the cloned object would automatically have the same class as self such that:
class MyElement < Element; end e = Myelement.new 'foo' other = e.clone other.class # -> MyElement (instead of Element)
would work as described.
BTW: Thanks for making REXML available!
Change History
Note: See
TracTickets for help on using
tickets.
