Class: Propono::TopicCreator
- Inherits:
-
Object
- Object
- Propono::TopicCreator
- Includes:
- Sns
- Defined in:
- lib/propono/services/topic_creator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #find_or_create ⇒ Object
-
#initialize(topic_id) ⇒ TopicCreator
constructor
A new instance of TopicCreator.
Constructor Details
#initialize(topic_id) ⇒ TopicCreator
Returns a new instance of TopicCreator.
12 13 14 |
# File 'lib/propono/services/topic_creator.rb', line 12 def initialize(topic_id) @topic_id = topic_id end |
Class Method Details
.find_or_create(topic_id) ⇒ Object
8 9 10 |
# File 'lib/propono/services/topic_creator.rb', line 8 def self.find_or_create(topic_id) new(topic_id).find_or_create end |
Instance Method Details
#find_or_create ⇒ Object
16 17 18 19 20 21 |
# File 'lib/propono/services/topic_creator.rb', line 16 def find_or_create result = sns.create_topic(@topic_id) body = result.body arn = body.fetch('TopicArn') { raise TopicCreatorError.new("No TopicArn returned from SNS") } Topic.new(arn) end |