Class: Resto::Request::Factory
- Inherits:
-
Object
- Object
- Resto::Request::Factory
- Extended by:
- Forwardable
- Defined in:
- lib/resto/request/factory.rb
Instance Method Summary collapse
- #delete ⇒ Object
- #delete! ⇒ Object
- #get ⇒ Object
- #get! ⇒ Object
- #head ⇒ Object
- #head! ⇒ Object
-
#initialize(request) ⇒ Factory
constructor
A new instance of Factory.
- #post ⇒ Object
- #post! ⇒ Object
- #put ⇒ Object
- #put! ⇒ Object
Constructor Details
#initialize(request) ⇒ Factory
Returns a new instance of Factory.
15 16 17 18 |
# File 'lib/resto/request/factory.rb', line 15 def initialize(request) @request = request @debug_request = false end |
Instance Method Details
#delete ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/resto/request/factory.rb', line 77 def delete http.start do |http| request = Net::HTTP::Delete.new(composed_path, composed_headers) print_request(request) http.request(request) end end |
#delete! ⇒ Object
72 73 74 75 |
# File 'lib/resto/request/factory.rb', line 72 def delete! @debug_request = true delete.tap { |response| print_response(response) } end |
#get ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/resto/request/factory.rb', line 38 def get http.start do |http| request = Net::HTTP::Get.new(composed_path, composed_headers) print_request(request) http.request(request) end end |
#get! ⇒ Object
33 34 35 36 |
# File 'lib/resto/request/factory.rb', line 33 def get! @debug_request = true get.tap { |response| print_response(response) } end |
#head ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/resto/request/factory.rb', line 25 def head http.start do |http| request = Net::HTTP::Head.new(composed_path, composed_headers) print_request(request) http.request(request) end end |
#head! ⇒ Object
20 21 22 23 |
# File 'lib/resto/request/factory.rb', line 20 def head! @debug_request = true head.tap { |response| print_response(response) } end |
#post ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/resto/request/factory.rb', line 51 def post http.start do |http| request = Net::HTTP::Post.new(composed_path, composed_headers) print_request(request) http.request(request, read_body) end end |
#post! ⇒ Object
46 47 48 49 |
# File 'lib/resto/request/factory.rb', line 46 def post! @debug_request = true post.tap { |response| print_response(response) } end |
#put ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/resto/request/factory.rb', line 64 def put http.start do |http| request = Net::HTTP::Put.new(composed_path, composed_headers) print_request(request) http.request(request, read_body) end end |
#put! ⇒ Object
59 60 61 62 |
# File 'lib/resto/request/factory.rb', line 59 def put! @debug_request = true put.tap { |response| print_response(response) } end |