views:

30

answers:

2

I have a class that inherits from class User.

eg

class MyClass < User

end

In my code base I have a class user

class User

end

However I also have a plugin that provides a User class in a module TheirModule::User. This is a plugin that my application is tied to and I cannot remove it at the moment, however that is what I would prefer to do.

From the console I can access MyClass and the inheritance is correctly determined. However when running the application there seems to be some confusion which User class I intend to inherit from and therefore the inheritance fails.

Is there a way to explicitly inherit from my User class and prevent confusion with the TheirModule::User

A: 
class MyUser < User
end

class MyClass < MyUser
end

This way MyClass will inherit from both your own MyUser class and from TheirModule::User.

Janteh
+1  A: 

If you want MyClass to inherit from User class, you can put the User class inside a module, for example MyModule.

class MyClass < MyModule::User
end
ubolonton
I'm not aware of any other solution rather than this one....
khelll
Is there anyway I can reference the default module in the class definition rather then having to shift it to a new module explicitly? The code bases this change would affect are quite fragile and a change of that scale would be non trivial.
lyallward