X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/efc2a3fa477f47b3c3c812fa32af5680f0632f4f..5a2ad3655bfb690ad98cd66877f35707783e0c9d:/app/models/user.rb 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