Class: Michael::Services::Github::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/michael/services/github/token.rb

Direct Known Subclasses

Initializer

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Token

Returns a new instance of Token.

Raises:



11
12
13
14
15
# File 'lib/michael/services/github/token.rb', line 11

def initialize(config)
  raise Michael::Error, 'config is nil' if config.nil?

  @config = config
end

Instance Method Details

#store(token) ⇒ Object



21
22
23
# File 'lib/michael/services/github/token.rb', line 21

def store(token)
  config.set(:token, value: token)
end

#tokenObject



25
26
27
# File 'lib/michael/services/github/token.rb', line 25

def token
  config.fetch(:token)
end

#validate(token) ⇒ Object

Raises:



17
18
19
# File 'lib/michael/services/github/token.rb', line 17

def validate(token)
  raise Michael::Error, 'access token must contain `repo` scope' unless scopes(token).include?('repo')
end