Class: MergetrainCheck::AuthTokenStorage

Inherits:
Object
  • Object
show all
Defined in:
lib/mergetrain_check/config.rb

Constant Summary collapse

KEYCHAIN_SERVICE_NAME =
'mergetrain_check'

Instance Method Summary collapse

Constructor Details

#initialize(host) ⇒ AuthTokenStorage

Returns a new instance of AuthTokenStorage.



8
9
10
11
12
# File 'lib/mergetrain_check/config.rb', line 8

def initialize(host)
  @host = host
  @kitem = Keychain.generic_passwords.where(service: KEYCHAIN_SERVICE_NAME).all.detect { |k| k. == host }
  @kitem = Keychain.generic_passwords.create(service: KEYCHAIN_SERVICE_NAME, password: 'secret', account: host) if @kitem.nil?
end

Instance Method Details

#passwordObject



14
15
16
# File 'lib/mergetrain_check/config.rb', line 14

def password
  return @kitem.password
end

#password=(value) ⇒ Object



18
19
20
# File 'lib/mergetrain_check/config.rb', line 18

def password=(value)
  @kitem.password = value
end

#save!Object



22
23
24
# File 'lib/mergetrain_check/config.rb', line 22

def save!
  @kitem.save!
end