class PgConn::RoleMethods
def list(database: nil, owner: false, superuser: nil, can_login: nil)
def list(database: nil, owner: false, superuser: nil, can_login: nil) database_clause = database && "rolname like '#{database}\\_\\_%'" database_clause = database && "(#{database_clause} or rolname = '#{database}')" if owner superuser_clause = superuser.nil? ? nil : "rolsuper = #{superuser}" can_login_clause = can_login.nil? ? nil : "rolcanlogin = #{can_login}" query = [ "select rolname from pg_roles where true", database_clause, superuser_clause, can_login_clause ].compact.join(" and ") conn.values(query) end