Class: HttpMimic::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/http_mimic/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, config = nil) ⇒ Client

Returns a new instance of Client.



7
8
9
10
# File 'lib/http_mimic/client.rb', line 7

def initialize(options = {}, config = nil)
  @default_options = options.dup
  @config = config || HttpMimic.configuration.dup
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



5
6
7
# File 'lib/http_mimic/client.rb', line 5

def config
  @config
end

#default_optionsObject

Returns the value of attribute default_options.



5
6
7
# File 'lib/http_mimic/client.rb', line 5

def default_options
  @default_options
end

Instance Method Details

#delete(url, options = {}) ⇒ Object



28
29
30
# File 'lib/http_mimic/client.rb', line 28

def delete(url, options = {})
  request(:delete, url, options)
end

#get(url, options = {}) ⇒ Object



12
13
14
# File 'lib/http_mimic/client.rb', line 12

def get(url, options = {})
  request(:get, url, options)
end

#head(url, options = {}) ⇒ Object



32
33
34
# File 'lib/http_mimic/client.rb', line 32

def head(url, options = {})
  request(:head, url, options)
end

#options(url, options = {}) ⇒ Object



36
37
38
# File 'lib/http_mimic/client.rb', line 36

def options(url, options = {})
  request(:options, url, options)
end

#patch(url, options = {}) ⇒ Object



24
25
26
# File 'lib/http_mimic/client.rb', line 24

def patch(url, options = {})
  request(:patch, url, options)
end

#post(url, options = {}) ⇒ Object



16
17
18
# File 'lib/http_mimic/client.rb', line 16

def post(url, options = {})
  request(:post, url, options)
end

#put(url, options = {}) ⇒ Object



20
21
22
# File 'lib/http_mimic/client.rb', line 20

def put(url, options = {})
  request(:put, url, options)
end

#request(method, url, options = {}) ⇒ Object



40
41
42
43
# File 'lib/http_mimic/client.rb', line 40

def request(method, url, options = {})
  merged_options = merge_options(@default_options, options)
  Request.new(method, url, merged_options, @config).perform
end