Class: Mayak::Http::Encoder::FromFunction

Inherits:
Object
  • Object
show all
Extended by:
T::Generic, T::Helpers, T::Sig
Includes:
Mayak::Http::Encoder
Defined in:
lib/mayak/http/encoder.rb

Constant Summary collapse

ResponseEntity =
type_member
ResponseType =
type_member {{ fixed: Mayak::Http::Response }}

Instance Method Summary collapse

Methods included from Encoder

#map_request

Constructor Details

#initialize(&function) ⇒ FromFunction

Returns a new instance of FromFunction.



45
46
47
# File 'lib/mayak/http/encoder.rb', line 45

def initialize(&function)
  @function = T.let(function, T.proc.params(response: ResponseEntity).returns(ResponseType))
end

Instance Method Details

#encode(entity) ⇒ Object



50
51
52
# File 'lib/mayak/http/encoder.rb', line 50

def encode(entity)
  @function.call(entity)
end