Class: MasonClient::HTTP
- Inherits:
-
Object
- Object
- MasonClient::HTTP
- Defined in:
- lib/mason_client/http.rb
Instance Method Summary collapse
- #fail! ⇒ Object
-
#initialize(url) ⇒ HTTP
constructor
A new instance of HTTP.
- #run(request) ⇒ Object
- #success! ⇒ Object
Constructor Details
#initialize(url) ⇒ HTTP
Returns a new instance of HTTP.
3 4 5 |
# File 'lib/mason_client/http.rb', line 3 def initialize(url) @url = url end |
Instance Method Details
#fail! ⇒ Object
21 22 23 |
# File 'lib/mason_client/http.rb', line 21 def fail! raise Error, "fail! can only be used when mocked" end |
#run(request) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/mason_client/http.rb', line 7 def run(request) response = Net::HTTP.post_form(URI(@url), "payload" => request.to_json) unless response.code == "301" return end response["Location"] end |
#success! ⇒ Object
17 18 19 |
# File 'lib/mason_client/http.rb', line 17 def success! raise Error, "success! can only be used when mocked" end |