Question: I'm directing users to a page on my site from email (possibly an email client). When they reach the site they are presented with login screen and the address where they were headed is lost. 

How can I capture the entire address that they were trying to visit, so that I can redirect them to it once they log in?

Answer: 
Here's a class

```
.A <-
    setRefClass("A",
                fields=list(x="numeric"),
                methods=list(foo=function() x))

```

If I had an instance `a` and wanted to construct a call to the 'foo' method using '$' I could

```
eval(substitute(a$FUN(), list(FUN="foo")))

```

So I'll create a class `Alist` that is meant to have a list of elements of class `A` (this could be enforced programmatically), and that has a `.delegate` method that'll apply an arbitrary method to all elements of the list. I'll then add a method that delegates `foo`.

```
.delegate <- function(FUN, ...)
{
    lapply(elts, function(elt, ...) {
        eval(substitute(elt$FUN(...), list(FUN=FUN, ...)))
    })
}

.Alist <-
    setRefClass("Alist",
                fields=list(elts="list"),
                methods=list(
                  initialize = function(...) callSuper(elts=list(...)),
                  .delegate = .delegate,
                  foo=function() .delegate("foo")))

```

And then use it

```
> aList <- .Alist$new(.A$new(x=1), .A$new(x=2))
> aList$foo()
[[1]]
[1] 1

[[2]]
[1] 2

```
basically R5 ref class does not cache the method until it is necessary. This is probably a kind of delayed evaluation.

And the caching takes place when you access the method via `$`.
So, AFAIK, there is no way to access the method via [[string]]

But you can find a workaround using .dollarForEnvRefClass like this:

```
> X <- new("Number", value = 1)
> ls(X@.xData)
[1] "value" # no methods named "addOne" before caching
> X[["addOne"]]
NULL
> methods:::.dollarForEnvRefClass(X, "addOne") # cache it
Class method definition for method addOne()
function () 
{
    value <<- value + 1
}
<environment: 0x116a4aa00>
> ls(X@.xData)
[1] "addOne" "value"  # you can find it
> X$value # value is 1
[1] 1
> X[["addOne"]]() # call the method
> X$value  # the method works
[1] 2

```

if you are interested in more detail, see the implementation:  

<http://svn.r-project.org/R/trunk/src/library/methods/R/refClass.R>

Maybe there is more straightforward way.