Class: Nestful::Endpoint
- Inherits:
-
Object
- Object
- Nestful::Endpoint
- Defined in:
- lib/nestful/endpoint.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #[](suburl) ⇒ Object
- #delete(params = {}, options = {}) ⇒ Object
- #get(params = {}, options = {}) ⇒ Object
-
#initialize(url, options = {}) ⇒ Endpoint
constructor
A new instance of Endpoint.
- #post(params = {}, options = {}) ⇒ Object
- #put(params = {}, options = {}) ⇒ Object
- #request(options = {}) ⇒ Object
Constructor Details
#initialize(url, options = {}) ⇒ Endpoint
Returns a new instance of Endpoint.
9 10 11 12 |
# File 'lib/nestful/endpoint.rb', line 9 def initialize(url, = {}) @url = url @options = end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/nestful/endpoint.rb', line 7 def url @url end |
Class Method Details
.[](url) ⇒ Object
3 4 5 |
# File 'lib/nestful/endpoint.rb', line 3 def self.[](url) self.new(url) end |
Instance Method Details
#[](suburl) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/nestful/endpoint.rb', line 14 def [](suburl) return self if suburl.nil? suburl = suburl.to_s base = url base += "/" unless base =~ /\/$/ self.class.new(URI.join(base, suburl).to_s, @options) end |
#delete(params = {}, options = {}) ⇒ Object
34 35 36 |
# File 'lib/nestful/endpoint.rb', line 34 def delete(params = {}, = {}) request(.merge(:method => :delete, :params => params)) end |
#get(params = {}, options = {}) ⇒ Object
22 23 24 |
# File 'lib/nestful/endpoint.rb', line 22 def get(params = {}, = {}) request(.merge(:method => :get, :params => params)) end |
#post(params = {}, options = {}) ⇒ Object
30 31 32 |
# File 'lib/nestful/endpoint.rb', line 30 def post(params = {}, = {}) request(.merge(:method => :post, :params => params)) end |
#put(params = {}, options = {}) ⇒ Object
26 27 28 |
# File 'lib/nestful/endpoint.rb', line 26 def put(params = {}, = {}) request(.merge(:method => :put, :params => params)) end |