|
7 | 7 | require_relative 'attribute'
|
8 | 8 | require_relative 'parsers/xpathparser'
|
9 | 9 |
|
10 |
| -class Object |
11 |
| - # provides a unified +clone+ operation, for REXML::XPathParser |
12 |
| - # to use across multiple Object types |
13 |
| - def dclone |
14 |
| - clone |
15 |
| - end |
16 |
| -end |
17 |
| -class Symbol |
18 |
| - # provides a unified +clone+ operation, for REXML::XPathParser |
19 |
| - # to use across multiple Object types |
20 |
| - def dclone ; self ; end |
21 |
| -end |
22 |
| -class Integer |
23 |
| - # provides a unified +clone+ operation, for REXML::XPathParser |
24 |
| - # to use across multiple Object types |
25 |
| - def dclone ; self ; end |
26 |
| -end |
27 |
| -class Float |
28 |
| - # provides a unified +clone+ operation, for REXML::XPathParser |
29 |
| - # to use across multiple Object types |
30 |
| - def dclone ; self ; end |
31 |
| -end |
32 |
| -class Array |
33 |
| - # provides a unified +clone+ operation, for REXML::XPathParser |
34 |
| - # to use across multiple Object+ types |
35 |
| - def dclone |
36 |
| - klone = self.clone |
37 |
| - klone.clear |
38 |
| - self.each{|v| klone << v.dclone} |
39 |
| - klone |
| 10 | +module REXML |
| 11 | + module DClonable |
| 12 | + refine Object do |
| 13 | + # provides a unified +clone+ operation, for REXML::XPathParser |
| 14 | + # to use across multiple Object types |
| 15 | + def dclone |
| 16 | + clone |
| 17 | + end |
| 18 | + end |
| 19 | + refine Symbol do |
| 20 | + # provides a unified +clone+ operation, for REXML::XPathParser |
| 21 | + # to use across multiple Object types |
| 22 | + def dclone ; self ; end |
| 23 | + end |
| 24 | + refine Integer do |
| 25 | + # provides a unified +clone+ operation, for REXML::XPathParser |
| 26 | + # to use across multiple Object types |
| 27 | + def dclone ; self ; end |
| 28 | + end |
| 29 | + refine Float do |
| 30 | + # provides a unified +clone+ operation, for REXML::XPathParser |
| 31 | + # to use across multiple Object types |
| 32 | + def dclone ; self ; end |
| 33 | + end |
| 34 | + refine Array do |
| 35 | + # provides a unified +clone+ operation, for REXML::XPathParser |
| 36 | + # to use across multiple Object+ types |
| 37 | + def dclone |
| 38 | + klone = self.clone |
| 39 | + klone.clear |
| 40 | + self.each{|v| klone << v.dclone} |
| 41 | + klone |
| 42 | + end |
| 43 | + end |
40 | 44 | end
|
41 | 45 | end
|
42 | 46 |
|
| 47 | +using REXML::DClonable |
| 48 | + |
43 | 49 | module REXML
|
44 | 50 | # You don't want to use this class. Really. Use XPath, which is a wrapper
|
45 | 51 | # for this class. Believe me. You don't want to poke around in here.
|
|
0 commit comments