Skip to content
This repository has been archived by the owner on Jul 31, 2022. It is now read-only.

Commit

Permalink
compact users so it works with users that have acts_as_paranoid
Browse files Browse the repository at this point in the history
  • Loading branch information
lawrencepit committed May 29, 2008
1 parent 66e6dda commit bf4e488
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions authorization/lib/publishare/identity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,18 @@ module InstanceMethods

def users
users = self.accepted_roles.collect { |role| role.users }
users.flatten.uniq if users
users.flatten.compact.uniq if users
end

def method_missing( method_sym, *args )
method_name = method_sym.to_s
if method_name =~ /^has_(\w+)\?$/
role_name = $1.singularize
self.accepted_roles.find_all_by_name(role_name).any? { |role| role.users.any? }
self.accepted_roles.find_all_by_name(role_name).any? { |role| role.users.compact.any? }
elsif method_name =~ /^has_(\w+)$/
role_name = $1.singularize
users = self.accepted_roles.find_all_by_name(role_name).collect { |role| role.users }
users.flatten.uniq if users
users.flatten.compact.uniq if users
else
super
end
Expand Down

0 comments on commit bf4e488

Please sign in to comment.