Class: Octoauth::Auth
- Inherits:
-
Object
- Object
- Octoauth::Auth
- Defined in:
- lib/octoauth/auth.rb
Overview
Authentication object
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Auth
constructor
A new instance of Auth.
- #save ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Auth
Returns a new instance of Auth.
24 25 26 27 28 29 30 31 32 |
# File 'lib/octoauth/auth.rb', line 24 def initialize(params = {}) params[:config_note] = "#{params[:note]}" if params[:api_endpoint] params[:config_note] << "--#{params[:api_endpoint]}" end @config = ConfigFile.new file: params[:file], note: params[:config_note] @token = load_token params save if params[:autosave] end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
22 23 24 |
# File 'lib/octoauth/auth.rb', line 22 def token @token end |
Instance Method Details
#save ⇒ Object
34 35 36 37 38 39 |
# File 'lib/octoauth/auth.rb', line 34 def save fail 'No token to save' unless @token fail 'No file given for config' unless @config.file @config.token = @token @config.write end |