File: parse_marshal.rb

package info (click to toggle)
ruby-faraday-middleware 1.2.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 376 kB
  • sloc: ruby: 2,388; sh: 15; makefile: 6
file content (15 lines) | stat: -rw-r--r-- 390 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# frozen_string_literal: true

require 'faraday_middleware/response_middleware'

module FaradayMiddleware
  # Public: Restore marshalled Ruby objects in response bodies.
  class ParseMarshal < ResponseMiddleware
    define_parser do |body|
      ::Marshal.load(body) unless body.empty?
    end
  end
end

# deprecated alias
Faraday::Response::ParseMarshal = FaradayMiddleware::ParseMarshal