construct_action {scenes}R Documentation

Construct a Scene Action

Description

Generate the check function for an action, and use it to create a scene_action object.

Usage

construct_action(fn, ..., negate = FALSE, methods = "GET")

Arguments

fn

A function that takes a request (and potentially other arguments) and returns TRUE or FALSE.

...

Additional parameters passed on to fn.

negate

If TRUE, trigger the corresponding scene when this action is not matched.

methods

The http methods which needs to be accepted in order for this function to make sense. Default "GET" should work in almost all cases.

Value

A scene_action object.

Examples

simple_function <- function(request) {
  !missing(request) && length(request) > 0
}
sample_action <- construct_action(simple_function)
sample_action$check_fn()
sample_action$check_fn(list())
sample_action$check_fn(list(a = 1))

[Package scenes version 0.1.0 Index]