/
class-item.R
80 lines (72 loc) · 1.72 KB
/
class-item.R
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#' Class Item
#'
#' Class Item
#'
#' Base class for describing a set of objects:
#' Project, Task, Pipeline, Files, etc.
#'
#' @field response save the raw response from a request.
#' @field auth_token propagate the auth_token from parent.
#' @field href API href
Item <- setRefClass(
"Item",
fields = list(
response = "ANY",
href = "characterORNULL",
auth = "AuthORNULL"
)
)
#' Get raw response from an Item object
#'
#' Get raw response from an Item object
#'
#' @param x object that may have response.
#' @param value value to be replaced.
#'
#' @return a raw response from httr
#'
#' @export
#' @docType methods
#' @rdname response-methods
#' @examples
#' \dontrun{
#' response(x)}
setGeneric("response", function(x) standardGeneric("response"))
#' @export
#' @docType methods
#' @rdname response-methods
setGeneric("response<-", function(x, value)
standardGeneric("response<-"))
#' @rdname response-methods
#' @aliases response,ANY-method
setMethod("response", "ANY", function(x) {
attr(x, "response")
})
#' @rdname response-methods
#' @aliases response<-,ANY-method
setReplaceMethod("response", "ANY", function(x, value) {
attr(x, "response") <- value
x
})
#' @rdname response-methods
#' @aliases response,Item-method
setMethod("response", "Item", function(x) {
x$response
})
#' @rdname response-methods
#' @aliases response<-,Item-method
setReplaceMethod("response", "Item", function(x, value) {
x$response <- value
x
})
#' @rdname response-methods
#' @aliases response,SimpleList-method
setMethod("response", "SimpleList", function(x) {
x@response
})
#' @rdname response-methods
#' @aliases response<-,SimpleList-method
setReplaceMethod("response", "SimpleList", function(x, value) {
x@response <- value
x
})