Class: Twurl::RequestController

Inherits:
AbstractCommandController show all
Defined in:
lib/twurl/request_controller.rb

Constant Summary collapse

NO_URI_MESSAGE =
"No URI specified"

Instance Attribute Summary

Attributes inherited from AbstractCommandController

#client, #options

Instance Method Summary collapse

Methods inherited from AbstractCommandController

dispatch, #initialize

Constructor Details

This class inherits a constructor from Twurl::AbstractCommandController

Instance Method Details

#dispatchObject



4
5
6
7
8
9
10
# File 'lib/twurl/request_controller.rb', line 4

def dispatch
  if client.needs_to_authorize?
    raise Exception, "You need to authorize first."
  end
  options.path ||= OAuthClient.rcfile.alias_from_options(options)
  perform_request
end

#perform_requestObject



12
13
14
15
16
17
18
# File 'lib/twurl/request_controller.rb', line 12

def perform_request
  client.perform_request_from_options(options) { |response|
    response.read_body { |chunk| CLI.print chunk }
  }
rescue URI::InvalidURIError
  CLI.puts NO_URI_MESSAGE
end