R/utils.R

Defines functions `%||%` get_function_name.aws_lambda_function get_function_name.character get_function_name print.aws_lambda_function

Documented in get_function_name get_function_name.aws_lambda_function get_function_name.character

print.aws_lambda_function <- function(x, ...) {
  print(utils::str(x))
  return(invisible(x))
}

#' @rdname get_function_name
#' @title Get name of Lambda function
#' @description Extracts an AWS Lambda function's name
#' @param x An object of class \dQuote{aws_lambda_function}.
#' @param \dots Additional arguments passed to methods
#' @export
get_function_name <- function(x, ...) {
  UseMethod("get_function_name")
}

#' @rdname get_function_name
#' @export
get_function_name.character <- function(x, ...) {
  x
}

#' @rdname get_function_name
#' @export
get_function_name.aws_lambda_function <- function(x, ...) {
  x[["FunctionName"]]
}

#' Default value for `NULL`
#'
#' This infix function makes it easy to replace `NULL`s with a default
#' value. It's inspired by the way that Ruby's or operation (`||`)
#' works. Copied from the rlang package.
#'
#' @param x,y If `x` is NULL, will return `y`; otherwise returns `x`.
#' @keywords internal
#' @name op-null-default
`%||%` <- function(x, y) {
  if (is.null(x)) y else x
}
cloudyr/aws.lambda documentation built on May 7, 2020, 11:54 p.m.