Class: Cased::CLI::Authentication
- Inherits:
-
Object
- Object
- Cased::CLI::Authentication
- Defined in:
- lib/cased/cli/authentication.rb
Instance Attribute Summary collapse
-
#credentials_path ⇒ Object
readonly
Returns the value of attribute credentials_path.
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
- #token ⇒ Object
Instance Method Summary collapse
- #exists? ⇒ Boolean
-
#initialize(token: nil) ⇒ Authentication
constructor
A new instance of Authentication.
Constructor Details
#initialize(token: nil) ⇒ Authentication
Returns a new instance of Authentication.
11 12 13 14 15 |
# File 'lib/cased/cli/authentication.rb', line 11 def initialize(token: nil) @token = token || Cased.config.guard_user_token @directory = Pathname.new(File.('~/.cguard')) @credentials_path = @directory.join('credentials') end |
Instance Attribute Details
#credentials_path ⇒ Object (readonly)
Returns the value of attribute credentials_path.
8 9 10 |
# File 'lib/cased/cli/authentication.rb', line 8 def credentials_path @credentials_path end |
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
8 9 10 |
# File 'lib/cased/cli/authentication.rb', line 8 def directory @directory end |
#token ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/cased/cli/authentication.rb', line 21 def token @token ||= begin credentials_path.read rescue Errno::ENOENT nil end end |
Instance Method Details
#exists? ⇒ Boolean
17 18 19 |
# File 'lib/cased/cli/authentication.rb', line 17 def exists? !token.nil? end |