| 21 | | |
|---|
| 22 | | # Return the constants that have been defined locally by this object and not |
|---|
| 23 | | # in an ancestor. This method may miss some constants if their definition in |
|---|
| 24 | | # the ancestor is identical to their definition in the receiver. |
|---|
| 25 | | def local_constants |
|---|
| 26 | | inherited = {} |
|---|
| 27 | | ancestors.each do |anc| |
|---|
| 28 | | next if anc == self |
|---|
| 29 | | anc.constants.each { |const| inherited[const] = anc.const_get(const) } |
|---|
| | 21 | |
|---|
| | 22 | if RUBY_VERSION < '1.9' |
|---|
| | 23 | # Return the constants that have been defined locally by this object and |
|---|
| | 24 | # not in an ancestor. This method is exact if running under Ruby 1.9. In |
|---|
| | 25 | # previous versions it may miss some constants if their definition in some |
|---|
| | 26 | # ancestor is identical to their definition in the receiver. |
|---|
| | 27 | def local_constants |
|---|
| | 28 | inherited = {} |
|---|
| | 29 | |
|---|
| | 30 | ancestors.each do |anc| |
|---|
| | 31 | next if anc == self |
|---|
| | 32 | anc.constants.each { |const| inherited[const] = anc.const_get(const) } |
|---|
| | 33 | end |
|---|
| | 34 | |
|---|
| | 35 | constants.select do |const| |
|---|
| | 36 | !inherited.key?(const) || inherited[const].object_id != const_get(const).object_id |
|---|
| | 37 | end |
|---|