Class: Yt::Models::Request
- Inherits:
-
Object
- Object
- Yt::Models::Request
- Defined in:
- lib/yt/models/request.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Request
constructor
A new instance of Request.
- #run ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Request
Returns a new instance of Request.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/yt/models/request.rb', line 15 def initialize( = {}) @auth = [:auth] @body = [:body] @body_type = .fetch :body_type, :json @expected_response = .fetch :expected_response, Net::HTTPSuccess @format = .fetch :format, :json @headers = .fetch :headers, {} @host = .fetch :host, google_api_host @method = .fetch :method, :get @path = [:path] @query = .fetch(:params, {}).to_param end |
Instance Method Details
#run ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/yt/models/request.rb', line 28 def run if response.is_a? @expected_response response.tap{|response| response.body = parse_format response.body} else run_again? ? run : raise(error_for(response), ) end end |