Connector: General connector object

ConnectorR Documentation

General connector object

Description

This R6 class is a general class for all connectors. It is used to define the methods that all connectors should have. New connectors should inherit from this class, and the methods described below should be implemented.

Methods

Public methods


Method new()

Initialize the connector with the option of adding an extra class.

Usage
Connector$new(extra_class = NULL)
Arguments
extra_class

character Extra class to assign to the new connector.


Method print()

Print method for a connector showing the registered methods and specifications from the active bindings.

Usage
Connector$print()
Returns

invisible self.


Method list_content_cnt()

List available content from the connector. See also list_content_cnt.

Usage
Connector$list_content_cnt(...)
Arguments
...

Additional arguments passed to the method for the individual connector.

Returns

A character vector of content names


Method read_cnt()

Read content from the connector. See also read_cnt.

Usage
Connector$read_cnt(name, ...)
Arguments
name

character Name of the content to read, write, or remove. Typically the table name.

...

Additional arguments passed to the method for the individual connector.

Returns

R object with the content. For rectangular data a data.frame.


Method write_cnt()

Write content to the connector.See also write_cnt.

Usage
Connector$write_cnt(x, name, ...)
Arguments
x

The object to write to the connection

name

character Name of the content to read, write, or remove. Typically the table name.

...

Additional arguments passed to the method for the individual connector.

Returns

invisible self.


Method remove_cnt()

Remove or delete content from the connector. See also remove_cnt.

Usage
Connector$remove_cnt(name, ...)
Arguments
name

character Name of the content to read, write, or remove. Typically the table name.

...

Additional arguments passed to the method for the individual connector.

Returns

invisible self.


Method clone()

The objects of this class are cloneable with this method.

Usage
Connector$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

See Also

vignette("customize") on how to create custom connectors and methods, and concrete examples in ConnectorFS and ConnectorDBI.

Examples

# Create connector
cnt <- Connector$new()

cnt

# Standard error message if no method is implemented
cnt |>
  read_cnt("fake_data") |>
  try()

# Connection with extra class
cnt_my_class <- Connector$new(extra_class = "my_class")

cnt_my_class

# Custom method for the extra class
read_cnt.my_class <- function(connector_object) "Hello!"
registerS3method("read_cnt", "my_class", "read_cnt.my_class")

cnt_my_class

read_cnt(cnt_my_class)

connector documentation built on June 8, 2025, 11:36 a.m.