Class: ActiveNotifier::Configurable::Configuration
- Inherits:
-
Object
- Object
- ActiveNotifier::Configurable::Configuration
- Defined in:
- lib/active_notifier/configurable.rb
Overview
Store the configuration data
Instance Attribute Summary collapse
-
#const_name ⇒ Object
Alias const for ActiveNotifier.
Instance Method Summary collapse
-
#adapter ⇒ Object
Message Adapter.
-
#adapter=(adapter) ⇒ Object
Set message Adapter.
-
#adapters_with_base_url ⇒ Object
The adapters and its base url.
-
#channel_tokens ⇒ Object
The tokens of channel.
-
#channel_tokens=(channel_tokens) ⇒ Object
Set the tokens of channel.
-
#priority_type ⇒ Object
The priority type for message, if notifier execute without type option and there are multiple valid types, then ActiveNotifier will use the template with this type first.
-
#priority_type=(priority_type) ⇒ Object
Set the priority type.
-
#template_home ⇒ Object
The template home directory.
-
#template_home=(template_home) ⇒ Object
Set the template home directory.
Instance Attribute Details
#const_name ⇒ Object
Alias const for ActiveNotifier
31 32 33 |
# File 'lib/active_notifier/configurable.rb', line 31 def const_name @const_name end |
Instance Method Details
#adapter ⇒ Object
Message Adapter
49 50 51 |
# File 'lib/active_notifier/configurable.rb', line 49 def adapter @adapter || :dingtalk end |
#adapter=(adapter) ⇒ Object
Set message Adapter
55 56 57 58 59 60 61 |
# File 'lib/active_notifier/configurable.rb', line 55 def adapter=(adapter) adapter = adapter.to_sym unless adapters_with_base_url.key?(adapter) raise ActiveNotifier::ConfigureError, "adapter only support: #{adapters_with_base_url.keys.join(', ')}" end @adapter = adapter end |
#adapters_with_base_url ⇒ Object
The adapters and its base url
106 107 108 109 110 |
# File 'lib/active_notifier/configurable.rb', line 106 def adapters_with_base_url @adapters_with_base_url ||= { dingtalk: "https://oapi.dingtalk.com/robot/send?access_token=" } end |
#channel_tokens ⇒ Object
The tokens of channel
64 65 66 |
# File 'lib/active_notifier/configurable.rb', line 64 def channel_tokens @channel_tokens || {} end |
#channel_tokens=(channel_tokens) ⇒ Object
Set the tokens of channel
75 76 77 78 |
# File 'lib/active_notifier/configurable.rb', line 75 def channel_tokens=(channel_tokens) channel_tokens = channel_tokens.to_h.symbolize_keys @channel_tokens = channel_tokens end |
#priority_type ⇒ Object
The priority type for message, if notifier execute without type option and there are multiple valid types, then ActiveNotifier will use the template with this type first
95 96 97 |
# File 'lib/active_notifier/configurable.rb', line 95 def priority_type @priority_type || :markdown end |
#priority_type=(priority_type) ⇒ Object
Set the priority type
101 102 103 |
# File 'lib/active_notifier/configurable.rb', line 101 def priority_type=(priority_type) @priority_type = priority_type.to_sym end |
#template_home ⇒ Object
The template home directory
81 82 83 |
# File 'lib/active_notifier/configurable.rb', line 81 def template_home @template_home || "#{File.(__dir__)}/templates" end |
#template_home=(template_home) ⇒ Object
Set the template home directory
87 88 89 90 91 |
# File 'lib/active_notifier/configurable.rb', line 87 def template_home=(template_home) template_home = template_home.to_s raise ActiveNotifier::ConfigureError, "template_home value can't be blank" if template_home.empty? @template_home = template_home end |