Class: TelegramOnSteroids::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/telegram_on_steroids/configuration.rb

Constant Summary collapse

REQUIRED_PARAMS =
%i(start_action api_token)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/telegram_on_steroids/configuration.rb', line 29

def initialize
  @client = TelegramOnSteroids::Client
  @webhook_params = {}

  if defined?(Rails)
    @session_store = Rails.cache
    @logger = Rails.logger
  else
    @session_store = InMemoryStore
    @logger = Logger.new(STDOUT)
  end
end

Instance Attribute Details

#api_tokenObject

Returns the value of attribute api_token.



24
25
26
# File 'lib/telegram_on_steroids/configuration.rb', line 24

def api_token
  @api_token
end

#clientObject

Returns the value of attribute client.



24
25
26
# File 'lib/telegram_on_steroids/configuration.rb', line 24

def client
  @client
end

#commandsObject

Returns the value of attribute commands.



24
25
26
# File 'lib/telegram_on_steroids/configuration.rb', line 24

def commands
  @commands
end

#loggerObject

Returns the value of attribute logger.



24
25
26
# File 'lib/telegram_on_steroids/configuration.rb', line 24

def logger
  @logger
end

#session_storeObject

Returns the value of attribute session_store.



24
25
26
# File 'lib/telegram_on_steroids/configuration.rb', line 24

def session_store
  @session_store
end

#start_actionObject

Returns the value of attribute start_action.



24
25
26
# File 'lib/telegram_on_steroids/configuration.rb', line 24

def start_action
  @start_action
end

#webhook_paramsObject

Returns the value of attribute webhook_params.



24
25
26
# File 'lib/telegram_on_steroids/configuration.rb', line 24

def webhook_params
  @webhook_params
end

#webhook_urlObject

Returns the value of attribute webhook_url.



24
25
26
# File 'lib/telegram_on_steroids/configuration.rb', line 24

def webhook_url
  @webhook_url
end

Instance Method Details

#verify!Object



42
43
44
45
46
47
48
# File 'lib/telegram_on_steroids/configuration.rb', line 42

def verify!
  blank_params = REQUIRED_PARAMS.select { |p| send(p).nil? }

  if blank_params.any?
    raise StandardError, blank_params
  end
end