File: adapter.rb

package info (click to toggle)
ruby-graphlient 0.5.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 2,648 kB
  • sloc: ruby: 1,288; makefile: 4
file content (41 lines) | stat: -rw-r--r-- 879 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
34
35
36
37
38
39
40
41
module Graphlient
  module Adapters
    module HTTP
      class Adapter
        attr_accessor :url, :options

        def initialize(url, options = {}, &_block)
          @url = url
          @options = options.dup if options
          yield self if block_given?
        end

        def headers
          options[:headers] if options
        end

        def http_options
          return {} unless options

          options[:http_options] || {}
        end

        def execute(*)
          raise NotImplementedError
        end

        private

        def configure_http_options(client_options)
          http_options.each do |k, v|
            begin
              client_options.send("#{k}=", v)
            rescue NoMethodError => e
              raise Graphlient::Errors::HttpOptionsError, e.message
            end
          end
        end
      end
    end
  end
end