class Cased::CLI::Authentication

Attributes

credentials_path[R]
directory[R]
token[W]

Public Class Methods

new(token: nil) click to toggle source
# File lib/cased/cli/authentication.rb, line 12
def initialize(token: nil)
  @token = token || Cased.config.guard_user_token
  @directory = Pathname.new(File.expand_path('~/.cguard'))
  @credentials_path = @directory.join('credentials')
end

Public Instance Methods

exists?() click to toggle source
# File lib/cased/cli/authentication.rb, line 18
def exists?
  !token.nil?
end
token() click to toggle source
# File lib/cased/cli/authentication.rb, line 22
def token
  @token ||= begin
    credentials_path.read
  rescue Errno::ENOENT
    nil
  end
end