File: pmatch_extensions.rb

package info (click to toggle)
ruby-httpx 1.7.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,816 kB
  • sloc: ruby: 12,209; makefile: 4
file content (33 lines) | stat: -rw-r--r-- 658 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

module HTTPX
  module ResponsePatternMatchExtensions
    def deconstruct
      [@status, @headers, @body]
    end

    def deconstruct_keys(_keys)
      { status: @status, headers: @headers, body: @body }
    end
  end

  module ErrorResponsePatternMatchExtensions
    def deconstruct
      [@error]
    end

    def deconstruct_keys(_keys)
      { error: @error }
    end
  end

  module HeadersPatternMatchExtensions
    def deconstruct
      to_a
    end
  end

  Headers.include HeadersPatternMatchExtensions
  Response.include ResponsePatternMatchExtensions
  ErrorResponse.include ErrorResponsePatternMatchExtensions
end