Learn R Programming

scenes (version 0.1.0)

construct_action: 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")

Value

A scene_action object.

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.

Examples

Run this code
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))

Run the code above in your browser using DataLab