Class: Apipony::Endpoint

Inherits:
Base
  • Object
show all
Defined in:
lib/apipony/endpoint.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, url, &block) ⇒ Endpoint

Returns a new instance of Endpoint.



4
5
6
7
8
9
# File 'lib/apipony/endpoint.rb', line 4

def initialize(method, url, &block)
  @method = method
  @url = set_base_url(url)

  instance_eval(&block) if block_given?
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



2
3
4
# File 'lib/apipony/endpoint.rb', line 2

def description
  @description
end

#methodObject

Returns the value of attribute method.



2
3
4
# File 'lib/apipony/endpoint.rb', line 2

def method
  @method
end

#requestObject

Returns the value of attribute request.



2
3
4
# File 'lib/apipony/endpoint.rb', line 2

def request
  @request
end

#responseObject

Returns the value of attribute response.



2
3
4
# File 'lib/apipony/endpoint.rb', line 2

def response
  @response
end

#urlObject

Returns the value of attribute url.



2
3
4
# File 'lib/apipony/endpoint.rb', line 2

def url
  @url
end

Instance Method Details

#idObject



19
20
21
# File 'lib/apipony/endpoint.rb', line 19

def id
  File.join(@method, @url)
end

#request_with(&block) ⇒ Object



15
16
17
# File 'lib/apipony/endpoint.rb', line 15

def request_with(&block)
  @request = Apipony::Request.new(&block)
end

#response_with(status, &block) ⇒ Object



11
12
13
# File 'lib/apipony/endpoint.rb', line 11

def response_with(status, &block)
  @response = Apipony::Response.new(status, &block)
end