M
Michael Schuerig
(1) Under what circumstances is an array not an Array? I'm confronted
with such a case in one of my unit tests. The test failed when run in
conjunction with other tests and I narrowed it down to this: In the
tested code I use something.kind_of?(Array). I have a mixin module that
extends Array with additional methods. When this module is required
directly or indirectly in my test class then kind_of?(Array) doesn't
behave as expected anymore.
(2) Maybe I'm not understanding Ruby's object system well enough. That
appears to be true in another case, too. I have a mixin module for
Enumerable whose methods I want to use on arrays, too, of course. But
apparently it is not enough to include it in Enumerable
Enumerable.module_eval do
include MyEnumExt
end
I have to do the same for Array to make it available there
Array.class_eval do
include MyEnumExt
end
Incidentally, I get the idea that (1) and (2) are related. But still I
don't understand what's happening.
Michael
with such a case in one of my unit tests. The test failed when run in
conjunction with other tests and I narrowed it down to this: In the
tested code I use something.kind_of?(Array). I have a mixin module that
extends Array with additional methods. When this module is required
directly or indirectly in my test class then kind_of?(Array) doesn't
behave as expected anymore.
(2) Maybe I'm not understanding Ruby's object system well enough. That
appears to be true in another case, too. I have a mixin module for
Enumerable whose methods I want to use on arrays, too, of course. But
apparently it is not enough to include it in Enumerable
Enumerable.module_eval do
include MyEnumExt
end
I have to do the same for Array to make it available there
Array.class_eval do
include MyEnumExt
end
Incidentally, I get the idea that (1) and (2) are related. But still I
don't understand what's happening.
Michael