module IdPlease module ModelExtensions module ForGroup def children(*args) options = args.extract_options! all_children = _auth_assign_class.role_name_eq(_auth_group_role).role_authorizable_eq(self).all(:include => :subject).collect(&:subject) if _auth_nested_groups == true && options[:nested] != false all_children.select { |child| child._auth_is_group == true }.each do |child| all_children << child.children end end all_children.flatten.uniq end def has_role!(role_name, object = nil) if object && object.kind_of?(self.class) && role_name.to_s == _auth_group_role && self.children.include?(object) raise "Attempt to make circular membership loop" else super end end end end end