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.



14
15
16
# File 'lib/circuitry/topic_creator.rb', line 14

def initialize(topic_name)
  @topic_name = topic_name
end

Instance Attribute Details

#topic_nameObject (readonly)

Returns the value of attribute topic_name.



8
9
10
# File 'lib/circuitry/topic_creator.rb', line 8

def topic_name
  @topic_name
end

Class Method Details

.find_or_create(topic_name) ⇒ Object



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

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

Instance Method Details

#topicObject



18
19
20
21
22
23
# File 'lib/circuitry/topic_creator.rb', line 18

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

  response = sns.create_topic(name: topic_name)
  @topic = Topic.new(response.topic_arn)
end