Class: FDK::Function
- Inherits:
-
Object
- Object
- FDK::Function
- Defined in:
- lib/fdk/function.rb
Overview
Function represents a function function or lambda
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#function ⇒ Object
readonly
Returns the value of attribute function.
Instance Method Summary collapse
- #as_proc ⇒ Object
- #call(request:, response:) ⇒ Object
-
#initialize(function:, format:) ⇒ Function
constructor
A new instance of Function.
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
#format ⇒ Object (readonly)
Returns the value of attribute format.
4 5 6 |
# File 'lib/fdk/function.rb', line 4 def format @format end |
#function ⇒ Object (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_proc ⇒ Object
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 |