Class: Osbourne::Topic

Inherits:
Object
  • Object
show all
Includes:
Services::SNS
Defined in:
lib/osbourne/topic.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Services::SNS

#sns, #sns=

Constructor Details

#initialize(name) ⇒ Topic

Returns a new instance of Topic.



8
9
10
11
12
# File 'lib/osbourne/topic.rb', line 8

def initialize(name)
  @name = name
  @prefixed_name = Osbourne.prefixer(name)
  arn
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/osbourne/topic.rb', line 6

def name
  @name
end

#prefixed_nameObject (readonly)

Returns the value of attribute prefixed_name.



7
8
9
# File 'lib/osbourne/topic.rb', line 7

def prefixed_name
  @prefixed_name
end

Instance Method Details

#arnObject



14
15
16
# File 'lib/osbourne/topic.rb', line 14

def arn
  @arn ||= ensure_topic
end

#publish(message) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/osbourne/topic.rb', line 18

def publish(message)
  parsed_message = parse(message)
  return if Osbourne.test_mode?

  Osbourne.logger.info "[Osbourne] [PUB] TOPIC: `#{prefixed_name}` MESSAGE: `#{parsed_message}`"
  sns.publish(topic_arn: arn, message: parsed_message)
end