Joined June 2013
·
Posted to
Ruby tricks to make your code more fun and less readable
over 1 year
ago
My 2 cents:
ActiveSupport`s String#strip_heredoc
case you
when -> y {y.happy?} then y.clap_hands #stolen from Avdi (?)
when PersonAnalyzer.method :hulk? then y.destroy!
end
- Shameless self-promotion: weekend experiment of mine. which allows something like:
puts mike.tell{"Call me #{name}. First thing you should know - don`t do business with #{cook.name}"}
or
gus = cast.find &which{ surname =~ /esposito/i }
but at the same time - still restricts protected and private methods:
https://github.com/idrozd/red_bikini
Posted to
Ruby `sort_by` Multiple Fields
over 1 year
ago
There is nothing to document here, it`s just a consequence of Array having <=> defined on it )
Achievements
103 Karma
3,545 Total ProTip Views
![](https://dj1symwmxvldi.cloudfront.net/assets/badges/mongoose3-3c4898df9b91ea4bec8bce0c83908998df630cbbf749d2dcfadba121af2bf1fa.png)
Mongoose 3
Have at least three original repos where Ruby is the dominant language
![](https://dj1symwmxvldi.cloudfront.net/assets/badges/raven-35923a69492045dffe4dfe0d7ebf31da4e76efabbbdaa090acd59d17debb3087.png)
Raven
Have at least one original repo where some form of shell script is the dominant language
![](https://dj1symwmxvldi.cloudfront.net/assets/badges/walrus-1f517cbbd8f030099b8386c53d4ee40fece3fa146b6362accb3abddb436482cb.png)
Walrus
The walrus is no stranger to variety. Use at least 4 different languages throughout all your repos
![](https://dj1symwmxvldi.cloudfront.net/assets/badges/charity-bab6d575c53894cc9e395db7cdb1f0f91f176fa0cc8122c5f824e672f3d556a4.png)
Charity
Fork and commit to someone's open source project in need
![](https://dj1symwmxvldi.cloudfront.net/assets/badges/mongoose-299fb33af2a4e416505b484d73e79ee3ff1840f3c7385d6bbbc158f76be054cb.png)
Mongoose
Have at least one original repo where Ruby is the dominant language
Is this still relevant?
I was thinking about having test-transaction-like functionality in development mode;
Like – submit a form, see what happens, and rollback by clicking some button.