J
Jarmo Pertman
I know that there are methods #kind_of?/#is_a? to check if one object
is a same type or a subclass of another object. But what if i want to
check if one object is in some module? For example:
module MyModule
class MyClass
end
end
m = MyModule::MyClass.new
m.kind_of?(MyModule) # => false
I would be happy if the statement above would return true since
MyClass is in module MyModule. Or why wouldn't it (except that it
hasn't meant to with current implementation)?
Anyway, i was hoping to find some other method for this kind of
checks, but was unable to find any from Class, Module, Object, Kernel
classes/modules. So i made one example myself: http://gist.github.com/503646
I still think that there should be some easier built-in way to perform
this kind of checks. Maybe i have just missed it...
Jarmo Pertman
is a same type or a subclass of another object. But what if i want to
check if one object is in some module? For example:
module MyModule
class MyClass
end
end
m = MyModule::MyClass.new
m.kind_of?(MyModule) # => false
I would be happy if the statement above would return true since
MyClass is in module MyModule. Or why wouldn't it (except that it
hasn't meant to with current implementation)?
Anyway, i was hoping to find some other method for this kind of
checks, but was unable to find any from Class, Module, Object, Kernel
classes/modules. So i made one example myself: http://gist.github.com/503646
I still think that there should be some easier built-in way to perform
this kind of checks. Maybe i have just missed it...
Jarmo Pertman