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.



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

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



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

def password
  return @kitem.password
end

#password=(value) ⇒ Object



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

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

#save!Object



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

def save!
  @kitem.save!
end