Class: Nestful::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/nestful/connection.rb

Constant Summary collapse

UriParser =
URI.const_defined?(:Parser) ? URI::Parser.new : URI

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endpoint, options = {}) ⇒ Connection

The endpoint parameter is required and will set the endpoint attribute to the URI for the remote resource service.



13
14
15
16
17
18
19
# File 'lib/nestful/connection.rb', line 13

def initialize(endpoint, options = {})
  self.endpoint = endpoint

  options.each do |key, value|
    self.send("#{key}=", value) unless value.nil?
  end
end

Instance Attribute Details

#endpointObject

Returns the value of attribute endpoint.



9
10
11
# File 'lib/nestful/connection.rb', line 9

def endpoint
  @endpoint
end

#proxyObject

Returns the value of attribute proxy.



9
10
11
# File 'lib/nestful/connection.rb', line 9

def proxy
  @proxy
end

#ssl_optionsObject

Returns the value of attribute ssl_options.



8
9
10
# File 'lib/nestful/connection.rb', line 8

def ssl_options
  @ssl_options
end

#timeoutObject

Returns the value of attribute timeout.



8
9
10
# File 'lib/nestful/connection.rb', line 8

def timeout
  @timeout
end

Instance Method Details

#delete(path, headers = {}, &block) ⇒ Object



35
36
37
# File 'lib/nestful/connection.rb', line 35

def delete(path, headers = {}, &block)
  request(:delete, path, headers, &block)
end

#get(path, headers = {}, &block) ⇒ Object



31
32
33
# File 'lib/nestful/connection.rb', line 31

def get(path, headers = {}, &block)
  request(:get, path, headers, &block)
end

#head(path, headers = {}, &block) ⇒ Object



39
40
41
# File 'lib/nestful/connection.rb', line 39

def head(path, headers = {}, &block)
  request(:head, path, headers, &block)
end

#patch(path, body = '', headers = {}, &block) ⇒ Object



47
48
49
# File 'lib/nestful/connection.rb', line 47

def patch(path, body = '', headers = {}, &block)
  request(:patch, path, body, headers, &block)
end

#post(path, body = '', headers = {}, &block) ⇒ Object



51
52
53
# File 'lib/nestful/connection.rb', line 51

def post(path, body = '', headers = {}, &block)
  request(:post, path, body, headers, &block)
end

#put(path, body = '', headers = {}, &block) ⇒ Object



43
44
45
# File 'lib/nestful/connection.rb', line 43

def put(path, body = '', headers = {}, &block)
  request(:put, path, body, headers, &block)
end