From: Tom Hughes Date: Thu, 1 Oct 2009 20:39:04 +0000 (+0000) Subject: Replace a couple calls to inject with more readble constructs. X-Git-Tag: live~6564^2~7 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/5a2ad3655bfb690ad98cd66877f35707783e0c9d Replace a couple calls to inject with more readble constructs. --- diff --git a/app/models/user.rb b/app/models/user.rb index 6ec9e26e6..54b3fa371 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -143,14 +143,14 @@ class User < ActiveRecord::Base ## # returns true if the user has the requested role def has_role?(role) - roles.inject(false) { |x, r| x or r.role == role } + roles.any? { |r| r.role == role } end ## # returns the first active block which would require users to view # a message, or nil if there are none. def blocked_on_view - active_blocks.inject(nil) { |s,x| s || (x.needs_view? ? x : nil) } + active_blocks.detect { |b| b.needs_view? } end def delete