From 5a2ad3655bfb690ad98cd66877f35707783e0c9d Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 1 Oct 2009 20:39:04 +0000 Subject: [PATCH 1/1] Replace a couple calls to inject with more readble constructs. --- app/models/user.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 -- 2.43.2