Class: Michael::Services::Github::Token
- Inherits:
-
Object
- Object
- Michael::Services::Github::Token
- Defined in:
- lib/michael/services/github/token.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(config) ⇒ Token
constructor
A new instance of Token.
- #store(token) ⇒ Object
- #token ⇒ Object
- #validate(token) ⇒ Object
Constructor Details
#initialize(config) ⇒ Token
Returns a new instance of Token.
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 |
#token ⇒ Object
25 26 27 |
# File 'lib/michael/services/github/token.rb', line 25 def token config.fetch(:token) end |
#validate(token) ⇒ Object
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 |