Class: TeamsConnector::Notification
- Defined in:
- lib/teams_connector/notification.rb,
lib/teams_connector/notification/message.rb,
lib/teams_connector/notification/adaptive_card.rb
Direct Known Subclasses
Defined Under Namespace
Classes: AdaptiveCard, Message
Instance Attribute Summary collapse
-
#channels ⇒ Object
Returns the value of attribute channels.
-
#template ⇒ Object
Returns the value of attribute template.
Instance Method Summary collapse
- #deliver_later ⇒ Object
-
#initialize(template: nil, channels: TeamsConnector.configuration.default) ⇒ Notification
constructor
A new instance of Notification.
- #pretty_print ⇒ Object
Constructor Details
#initialize(template: nil, channels: TeamsConnector.configuration.default) ⇒ Notification
12 13 14 15 |
# File 'lib/teams_connector/notification.rb', line 12 def initialize(template: nil, channels: TeamsConnector.configuration.default) @template = template @channels = channels.instance_of?(Array) ? channels : [channels] end |
Instance Attribute Details
#channels ⇒ Object
Returns the value of attribute channels.
10 11 12 |
# File 'lib/teams_connector/notification.rb', line 10 def channels @channels end |
#template ⇒ Object
Returns the value of attribute template.
10 11 12 |
# File 'lib/teams_connector/notification.rb', line 10 def template @template end |
Instance Method Details
#deliver_later ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/teams_connector/notification.rb', line 17 def deliver_later template_path = find_template renderer = ERB.new(File.read(template_path)) renderer.location = [template_path.to_s, 0] content = renderer.result(binding) channels = TeamsConnector.configuration.always_use_default ? [TeamsConnector.configuration.default] : @channels channels.each do |channel| deliver_channel(channel, content) end end |
#pretty_print ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/teams_connector/notification.rb', line 31 def pretty_print template_path = find_template renderer = ERB.new(File.read(template_path)) renderer.location = [template_path.to_s, 0] content = renderer.result(binding) puts JSON.pretty_generate(JSON.parse(content)) end |