Class: Konsierge::Notifier::Configuration
- Inherits:
-
Object
- Object
- Konsierge::Notifier::Configuration
- Defined in:
- lib/konsierge/notifier/configuration.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- ADAPTER_IMPLEMENTATIONS =
{ telegram: Adapters::Telegram }.freeze
Instance Attribute Summary collapse
-
#adapter ⇒ Object
Returns the value of attribute adapter.
-
#app_name ⇒ Object
Returns the value of attribute app_name.
-
#bot_enabled ⇒ Object
Returns the value of attribute bot_enabled.
-
#chat_id ⇒ Object
Returns the value of attribute chat_id.
-
#error_template_path ⇒ Object
Returns the value of attribute error_template_path.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#message_template_path ⇒ Object
Returns the value of attribute message_template_path.
-
#parse_mode ⇒ Object
Returns the value of attribute parse_mode.
Instance Method Summary collapse
- #adapter_class ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/konsierge/notifier/configuration.rb', line 17 def initialize @app_name = nil @adapter = :telegram @chat_id = ENV.fetch('TELEGRAM_CHANNEL_ID', nil) @bot_enabled = ENV.fetch('TELEGRAM_BOT_ENABLED', false) = File.('templates/telegram/message.html.erb', __dir__) @error_template_path = File.('templates/telegram/error.html.erb', __dir__) @logger = Logger.new($stdout) @parse_mode = 'HTML' end |
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter.
14 15 16 |
# File 'lib/konsierge/notifier/configuration.rb', line 14 def adapter @adapter end |
#app_name ⇒ Object
Returns the value of attribute app_name.
14 15 16 |
# File 'lib/konsierge/notifier/configuration.rb', line 14 def app_name @app_name end |
#bot_enabled ⇒ Object
Returns the value of attribute bot_enabled.
14 15 16 |
# File 'lib/konsierge/notifier/configuration.rb', line 14 def bot_enabled @bot_enabled end |
#chat_id ⇒ Object
Returns the value of attribute chat_id.
14 15 16 |
# File 'lib/konsierge/notifier/configuration.rb', line 14 def chat_id @chat_id end |
#error_template_path ⇒ Object
Returns the value of attribute error_template_path.
14 15 16 |
# File 'lib/konsierge/notifier/configuration.rb', line 14 def error_template_path @error_template_path end |
#logger ⇒ Object
Returns the value of attribute logger.
14 15 16 |
# File 'lib/konsierge/notifier/configuration.rb', line 14 def logger @logger end |
#message_template_path ⇒ Object
Returns the value of attribute message_template_path.
14 15 16 |
# File 'lib/konsierge/notifier/configuration.rb', line 14 def end |
#parse_mode ⇒ Object
Returns the value of attribute parse_mode.
14 15 16 |
# File 'lib/konsierge/notifier/configuration.rb', line 14 def parse_mode @parse_mode end |
Instance Method Details
#adapter_class ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/konsierge/notifier/configuration.rb', line 34 def adapter_class unless ADAPTER_IMPLEMENTATIONS[@adapter] error_msg = "#{@adapter} must be one of #{ADAPTER_IMPLEMENTATIONS.keys.join(', ')}" raise Error, error_msg end ADAPTER_IMPLEMENTATIONS[@adapter.to_s.to_sym] end |
#to_h ⇒ Object
28 29 30 31 32 |
# File 'lib/konsierge/notifier/configuration.rb', line 28 def to_h instance_variables.each_with_object({}) do |var, hash| hash[var.to_s.delete('@').to_sym] = instance_variable_get(var) end end |