From: Calvin Bornhofen Date: 2013-01-10T07:33:40+09:00 Subject: Re: Extending class Hello, I don't know if my tip applies for you (haven't worked with neither Rails nor Mongoid), but your scenario looks like subclassing is the way to go; you have a UserForForum class, which is a more specialized form of User. A way of extending a class like a module doesn't exist in Ruby afaik. Regards, Calvin On 09.01.2013 23:12, Damjan Rems wrote: > In my scenario somewhere in the future someone would make a gem, which > would need to extend User class. I found out that it can be done this > way: > > User::field :signature, type: String > User::belongs_to :visit > User::embeds_many :roles > > but it is kinda ugly. Then I realize that extend keyword exists, but it > is possible to extend only modules not classes. So this realy nice > example would work only if User is a module. > > class UserForForum > extend User > > field :signature, type: String > > belongs_to :visit > embeds_many :roles > end > > Is there a clear way of extending classes?