[Talking-Ruby] ActiveSupport Delegate module implement the delegation pattern
If your project includes ActiveSupport
, and every Rails project does, you have a more clean and easy way to implement the delegation pattern: the Module#delegate
extension. It provides a delegate module you can use in your class or in your modules to delegate a specific method to an associate object.
#delegate
provides a delegate class method to easily expose contained objects’ public methods as your own.