File: marshal.rb

package info (click to toggle)
ruby-typhoeus 1.4.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 636 kB
  • sloc: ruby: 4,381; makefile: 6
file content (22 lines) | stat: -rw-r--r-- 694 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module Typhoeus
  class Request

    # This module contains custom serializer.
    module Marshal

      # Return the important data needed to serialize this Request, except the
      # request callbacks and `hydra`, since they cannot be marshalled.
      def marshal_dump
        unmarshallable = %w(@on_complete @on_success @on_failure @on_progress @on_headers @on_body @hydra)
        (instance_variables - unmarshallable - unmarshallable.map(&:to_sym)).map do |name|
          [name, instance_variable_get(name)]
        end
      end

      # Load.
      def marshal_load(attributes)
        attributes.each { |name, value| instance_variable_set(name, value) }
      end
    end
  end
end