Class: XSR::Client
- Inherits:
-
Object
- Object
- XSR::Client
- Defined in:
- lib/xsr/client.rb
Overview
XSR Client class, holding methods to handle HTTP requests
Instance Attribute Summary collapse
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#default_header ⇒ Object
Returns the value of attribute default_header.
Instance Method Summary collapse
- #delete(path, options = {}) ⇒ Object
- #get(path, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #post(path, options = {}) ⇒ Object
- #put(path, options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
7 8 9 10 |
# File 'lib/xsr/client.rb', line 7 def initialize( = {}) @base_url = [:base_url] @base_header = [:header] end |
Instance Attribute Details
#base_url ⇒ Object
Returns the value of attribute base_url.
4 5 6 |
# File 'lib/xsr/client.rb', line 4 def base_url @base_url end |
#default_header ⇒ Object
Returns the value of attribute default_header.
5 6 7 |
# File 'lib/xsr/client.rb', line 5 def default_header @default_header end |
Instance Method Details
#delete(path, options = {}) ⇒ Object
16 17 18 |
# File 'lib/xsr/client.rb', line 16 def delete(path, = {}) request_with_data(path, ) { |uri| Net::HTTP::Delete.new(uri.to_s) } end |
#get(path, options = {}) ⇒ Object
24 25 26 |
# File 'lib/xsr/client.rb', line 24 def get(path, = {}) request_with_data(path, ) { |uri| Net::HTTP::Get.new(uri.to_s) } end |
#post(path, options = {}) ⇒ Object
12 13 14 |
# File 'lib/xsr/client.rb', line 12 def post(path, = {}) request_with_data(path, ) { |uri| Net::HTTP::Post.new(uri.to_s) } end |
#put(path, options = {}) ⇒ Object
20 21 22 |
# File 'lib/xsr/client.rb', line 20 def put(path, = {}) request_with_data(path, ) { |uri| Net::HTTP::Put.new(uri.to_s) } end |