class FDK::Function

Function represents a function function or lambda

Attributes

format[R]
function[R]

Public Class Methods

new(function:, format:) click to toggle source
# File lib/fdk/function.rb, line 23
def initialize(function:, format:)
  raise "'#{format}' not supported in Ruby FDK." unless format == "http-stream"

  @format = format
  @function = function
end

Public Instance Methods

as_proc() click to toggle source
# File lib/fdk/function.rb, line 30
def as_proc
  return function if function.respond_to?(:call)

  ->(context:, input:) { send(function, context: context, input: input) }
end
call(request:, response:) click to toggle source
# File lib/fdk/function.rb, line 36
def call(request:, response:)
  Call.new(request: request, response: response).process(&as_proc)
end