This project is archived and is in readonly mode.
Object#nonblank? (analogous to Ruby's Numeric#nonzero?)
-
Colin Kelley
[oops, reformatting]
For example, this:
state = params[:state] unless params[:state].blank? country = params[:country] unless params[:country].blank? region = state || country || 'US'becomes:
region = params[:state].nonblank? || params[:country].nonblank? || 'US' -
Prem Sichanugrist (sikachu)
I have some suggestion. Since we already have
present?method which would do almost the same thing. Should we modifypresent?method return object itself if it's notblank?instead?region = params[:state].present? || params[:country].present? || 'US'
