Class: Twurl::ConfigurationController

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

Constant Summary collapse

UNRECOGNIZED_SETTING_MESSAGE =
"Unknown configuration setting: '%s'"

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
11
12
13
14
15
16
17
18
19
20
# File 'lib/twurl/configuration_controller.rb', line 4

def dispatch
  case options.subcommands.first
  when 'default'
    if profile = case options.subcommands.size
                 when 2
                   OAuthClient.load_client_for_username(options.subcommands.last)
                 when 3
                   OAuthClient.load_client_for_username_and_consumer_key(*options.subcommands[-2, 2])
                 end

      OAuthClient.rcfile.default_profile = profile
      OAuthClient.rcfile.save
    end
  else
    CLI.puts(UNRECOGNIZED_SETTING_MESSAGE % options.subcommands.first)
  end
end