Class: HttpClientGenerator::Plugs::SetHeader
- Inherits:
-
Object
- Object
- HttpClientGenerator::Plugs::SetHeader
- Defined in:
- lib/http_client_generator/plugs/set_header.rb
Instance Method Summary collapse
- #call(req) ⇒ Object
-
#initialize(arg: nil, value: nil, header:, func: nil) ⇒ SetHeader
constructor
A new instance of SetHeader.
Constructor Details
#initialize(arg: nil, value: nil, header:, func: nil) ⇒ SetHeader
Returns a new instance of SetHeader.
8 9 10 11 12 13 |
# File 'lib/http_client_generator/plugs/set_header.rb', line 8 def initialize(arg: nil, value: nil, header:, func: nil) @arg = arg @header = header @func = func @value = value end |
Instance Method Details
#call(req) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/http_client_generator/plugs/set_header.rb', line 15 def call(req) return process_header_value(req) if @value arg = req.rest_args[@arg] req.headers[@header] = case @func&.arity in 1 @func.(arg) in 2 @func.(req, arg) in nil arg end req end |