> We already have Object#present? :)True, but present? is just the inverse of blank?. What we've found
very useful is to have a method that treats blank parameters the same
as missing ones, and allows chaining.
Check out the example:
state = params[:state] unless params[:state].blank?
Rewriting with present? isn't any more expressive:
state = params[:state] if params[:state].present?
But nonblank? makes it more concise and expressive IMO:
region = params[:state].nonblank? || params[:country].nonblank? ||
We've been using it this way for the last year and it really has
I suppose we could keep the method name present? but switch its
I like the symmetrical pair of nonzero? and nonblank? because they map
On Dec 27, 5:37 am, Pratik <pratikn...@gmail.com> wrote:
> We already have Object#present? :)
> On Sun, Dec 27, 2009 at 7:49 AM, ColinDKelley <colindkel...@gmail.com> wrote:
> > I'd like to propose the Object#nonblank? in ActiveSupport, layered
> > It is analogous to Ruby's Numeric#nonzero? method: it either returns
> > For example, this:
> > state = params[:state] unless params[:state].blank?
> > becomes:
> > region = params[:state].nonblank? || params[:country].nonblank? ||
> > The ticket is here:
> > along with a patch that includes full documentation and tests.
> > --
> > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.