When you import a module into a class, is it similar in nature to OOP composition?
views:
56answers:
2
+5
A:
No, it's more like multiple inheritance, but not completely the same. Modules can be used to mix-in functionality, so you don't have to rewrite the same code for multiple classes. Composition is where objects hold references to other objects.
Wouter de Bie
2010-10-09 16:28:39
A:
I may be getting my design pattern terminology mixed up, but have you looked at def_delegator
and def_delegators
from Ruby's standard library forwardable
?
Andrew Grimm
2010-10-09 19:54:52