Class: Served::HTTPClient

Inherits:
Object
  • Object
show all
Defined in:
lib/served/http_client.rb

Overview

Provides an interface between the HTTP client and the Resource.

Defined Under Namespace

Classes: ConnectionFailed

Constant Summary collapse

DEFAULT_TEMPLATE =
'{/resource*}{/id}.json{?query*}'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource) ⇒ HTTPClient

Returns a new instance of HTTPClient.



20
21
22
23
24
25
# File 'lib/served/http_client.rb', line 20

def initialize(resource)
  @resource = resource
  h = host + @resource.template
  @template = Addressable::Template.new(h)
  @backend  = Served::Backends[Served.config.backend].new(self)
end

Instance Attribute Details

#resourceObject (readonly)

Returns the value of attribute resource.



9
10
11
# File 'lib/served/http_client.rb', line 9

def resource
  @resource
end

#templateObject (readonly)

Returns the value of attribute template.



9
10
11
# File 'lib/served/http_client.rb', line 9

def template
  @template
end