File: getDispatchMethodS3.R

package info (click to toggle)
r-cran-r.methodss3 1.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 300 kB
  • sloc: sh: 12; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 1,112 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
###########################################################################/**
# @RdocDefault getDispatchMethodS3
#
# @title "Gets the S3 method that a generic function would call"
#
# \description{
#  @get "title" according to an S3 @see "base::class" @vector.
# }
#
# @synopsis
#
# \arguments{
#   \item{methodName}{A @character string specifying the name of a
#     generic function.}
#   \item{classNames}{A @character @vector of @see "base::class" names.}
#   \item{...}{Not used.}
# }
#
# \value{
#   Returns a @function, or throws an exception if not found.
# }
#
# \seealso{
#   @see "findDispatchMethodsS3".
# }
#
# @author
#
# @keyword programming
# @keyword methods
# @keyword internal
#*/###########################################################################
setMethodS3("getDispatchMethodS3", "default", function(methodName, classNames, ...) {
  res <- findDispatchMethodsS3(methodName, classNames, firstOnly=TRUE, ...)
  if (length(res) == 0) {
    stop(sprintf("No method %s() for this class structure: %s", methodName, paste(classNames, collapse=", ")))
  }

  res[[1]]$fcn
}, private=TRUE)