Class: Circuitry::TopicCreator

Inherits:
Object
  • Object
show all
Includes:
Services::SNS
Defined in:
lib/circuitry/topic_creator.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Services::SNS

#sns

Constructor Details

#initialize(topic_name) ⇒ TopicCreator

Returns a new instance of TopicCreator.



16
17
18
# File 'lib/circuitry/topic_creator.rb', line 16

def initialize(topic_name)
  @topic_name = topic_name
end

Instance Attribute Details

#topic_nameObject (readonly)

Returns the value of attribute topic_name.



10
11
12
# File 'lib/circuitry/topic_creator.rb', line 10

def topic_name
  @topic_name
end

Class Method Details

.find_or_create(topic_name) ⇒ Object



12
13
14
# File 'lib/circuitry/topic_creator.rb', line 12

def self.find_or_create(topic_name)
  new(topic_name).topic
end

Instance Method Details

#topicObject



20
21
22
23
24
25
26
# File 'lib/circuitry/topic_creator.rb', line 20

def topic
  return @topic if defined?(@topic)

  response = sns.create_topic(topic_name)
  arn = response.body.fetch('TopicArn') { raise TopicCreatorError.new('No TopicArn returned from SNS') }
  @topic = Topic.new(arn)
end