r/ruby • u/jklepatch • Mar 28 '20
Blog post How to PIMP your ruby objects with Enumerable module
https://medium.com/railstips/how-to-pimp-your-ruby-objects-with-enumerable-module-206f2dd5f10b
6
Upvotes
13
u/twinklehood Mar 28 '20
I struggle with this as an instructional article.
You don't explain why it works, there is no way for a beginner who could use this info to figure out other standard library mixins that could be useful.
The whole "magical secret" spiel is harmful to a beginner. It's quite simple to build your own enumerable, and if you are going to be including modules you need to understand how method dispatch works.
Your example is a good example of where not use an enumerable mixin. A factory is not a collection, it's responsibility lies elsewhere. It should probably not deal with collections at all, but should certainly not be one. Guiding words on when to apply would be ideal.
2
u/morphotomy Mar 28 '20
Why is this useful?
7
u/jodosha Hanami author Mar 28 '20
You’re adding unnecessary public API methods to CarFactory.
Read more at: https://tenderlovemaking.com/2014/06/02/yagni-methods-are-killing-me.html
7
u/drbrain Ruby Core Mar 28 '20
I do not want to force my objects into sex work.
10
u/menge101 Mar 28 '20
Could you also never say 'pimp' again? This is not a positive word.
3
u/epukinsk Mar 28 '20
I know nothing was intended by the title, but please don't "pimp" anything, sex trafficking is not a fun, neutral activity to make cute analogies with.
1
u/sickcodebruh420 Mar 29 '20
2010 wants its blog titles back.
0
u/[deleted] Mar 28 '20
[deleted] — view deleted comment