Class: FDK::Function

Inherits:
Object
  • Object
show all
Defined in:
lib/fdk/function.rb

Overview

Function represents a function function or lambda

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(function:, format:) ⇒ Function

Returns a new instance of Function.



23
24
25
26
27
28
# 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

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



22
23
24
# File 'lib/fdk/function.rb', line 22

def format
  @format
end

#functionObject (readonly)

Returns the value of attribute function.



22
23
24
# File 'lib/fdk/function.rb', line 22

def function
  @function
end

Instance Method Details

#as_procObject



30
31
32
33
34
# 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:) ⇒ Object



36
37
38
# File 'lib/fdk/function.rb', line 36

def call(request:, response:)
  Call.new(request: request, response: response).process(&as_proc)
end