Class: Pheme::TopicPublisher
- Inherits:
-
Object
- Object
- Pheme::TopicPublisher
- Defined in:
- lib/pheme/topic_publisher.rb
Instance Attribute Summary collapse
-
#topic_arn ⇒ Object
Returns the value of attribute topic_arn.
Instance Method Summary collapse
-
#initialize(topic_arn:) ⇒ TopicPublisher
constructor
A new instance of TopicPublisher.
- #publish(message) ⇒ Object
- #publish_events ⇒ Object
- #serialize(message) ⇒ Object
Constructor Details
#initialize(topic_arn:) ⇒ TopicPublisher
Returns a new instance of TopicPublisher.
5 6 7 8 |
# File 'lib/pheme/topic_publisher.rb', line 5 def initialize(topic_arn:) raise ArgumentError, "must specify non-nil topic_arn" unless topic_arn.present? @topic_arn = topic_arn end |
Instance Attribute Details
#topic_arn ⇒ Object
Returns the value of attribute topic_arn.
3 4 5 |
# File 'lib/pheme/topic_publisher.rb', line 3 def topic_arn @topic_arn end |
Instance Method Details
#publish(message) ⇒ Object
14 15 16 17 |
# File 'lib/pheme/topic_publisher.rb', line 14 def publish() Pheme.log(:info, "Publishing to #{topic_arn}: #{}") Pheme.configuration.sns_client.publish(topic_arn: topic_arn, message: serialize()) end |
#publish_events ⇒ Object
10 11 12 |
# File 'lib/pheme/topic_publisher.rb', line 10 def publish_events raise NotImplementedError end |
#serialize(message) ⇒ Object
19 20 21 22 |
# File 'lib/pheme/topic_publisher.rb', line 19 def serialize() return if .is_a? String .to_json end |