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



5
6
7
8
9
10
# File 'lib/fdk/function.rb', line 5

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.



4
5
6
# File 'lib/fdk/function.rb', line 4

def format
  @format
end

#functionObject (readonly)

Returns the value of attribute function.



4
5
6
# File 'lib/fdk/function.rb', line 4

def function
  @function
end

Instance Method Details

#as_procObject



12
13
14
15
16
# File 'lib/fdk/function.rb', line 12

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

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

#call(request:, response:) ⇒ Object



18
19
20
# File 'lib/fdk/function.rb', line 18

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