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.



24
25
26
27
28
29
# File 'lib/fdk/function.rb', line 24

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



31
32
33
34
35
# File 'lib/fdk/function.rb', line 31

def as_proc
  return function if function.respond_to?(:call)

  ->(context:, input:) { send(function, context: context, input: input) }
end

#call(request:, response:) ⇒ Object



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

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