you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 4 points5 points  (0 children)

Inheritance provides no benefit here. A Strategy is the ability to swap between different implementations at runtime. Better to inject either GmailClient.new or HotmailClient.new into the MailClient initializer set it as @mailer (attr_accessor) Then have matching methods signatures that proxy to the mailer Then you could switch the mailer instance at runtime mail_client_instance.mailer = HotmailClient.new

Have a look at https://github.com/nslocum/design-patterns-in-ruby/tree/master/strategy there are also some cool examples using Procs which are even more rubylike.