Skip to content

Commit

Permalink
mention to export methods
Browse files Browse the repository at this point in the history
  • Loading branch information
DivadNojnarg committed Nov 14, 2024
1 parent 61b6fc1 commit 84cb37a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/registry.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ get_s3_method <- function(generic, obj) {
}
}

stop("no method found for generic ", generic, "and classes ",
stop("no method found for generic ", generic, " and classes ",
paste0(class(obj), collapse = ", "))
}

Expand Down
4 changes: 3 additions & 1 deletion vignettes/registry.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,10 @@ new_tail_block <- function(data, n_rows = numeric(), ...) {
}
```

In addition to that, you also might have to specify what kind of __input__ and __output__ are accepted by that block. We designed 2 helpers, namely `block_input_check()` and `block_output_ptype()`. `{blockr}` already exposes methods for `data_block` and `transform_block` so you don't need to create a new method for those classes. However, we see a practical example on how to create such methods for plots in this [vignette](https://bristolmyerssquibb.github.io/blockr/articles/plot-block.html). Below is what these methods look like:
In addition to that, you also might have to specify what kind of __input__ and __output__ are accepted by that block. We designed 2 helpers, namely `block_input_check()` and `block_output_ptype()`. `{blockr}` already exposes methods for `data_block` and `transform_block` so you don't need to create a new method for those classes. However, we see a practical example on how to create such methods for plots in this [vignette](https://bristolmyerssquibb.github.io/blockr/articles/plot-block.html). Below is what these methods look like, don't forget to export them if you are running inside a R package:

```r
#' @export
block_input_check.transform_block <- function(x, data, ...) {

if (inherits(data, "data.frame")) {
Expand All @@ -194,6 +195,7 @@ block_input_check.transform_block <- function(x, data, ...) {

input_failure("Expecting data.frame input.")
}
#' @export
block_output_ptype.transform_block <- function(x, ...) data.frame()
```

Expand Down

0 comments on commit 84cb37a

Please sign in to comment.