Class: Telegram::Auth::Configuration

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/telegram/auth/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#auth_expires_inObject

Returns the value of attribute auth_expires_in.



7
8
9
# File 'lib/telegram/auth/configuration.rb', line 7

def auth_expires_in
  @auth_expires_in
end

#tokenObject

Returns the value of attribute token.



6
7
8
# File 'lib/telegram/auth/configuration.rb', line 6

def token
  @token
end

Instance Method Details

#reset!Object



24
25
26
27
# File 'lib/telegram/auth/configuration.rb', line 24

def reset!
  self.token = nil
  self.auth_expires_in = nil
end

#valid?Boolean

Returns:

  • (Boolean)


9
10
11
12
13
# File 'lib/telegram/auth/configuration.rb', line 9

def valid?
  @errors = []
  @errors << ConfigurationError.new("Invalid token") if (!token || token.empty?)
  @errors.none?
end

#validate!Object



15
16
17
# File 'lib/telegram/auth/configuration.rb', line 15

def validate!
  valid? or raise @errors.first
end

#verify!Object



19
20
21
22
# File 'lib/telegram/auth/configuration.rb', line 19

def verify!
  return true if valid?
  raise @errors.shift
end