class SimpleMessageQueue::Notification::Topic
Attributes
sns_topic[R]
Public Class Methods
find(name)
click to toggle source
# File lib/simple_message_queue/notification.rb, line 19 def find(name) topic_name = topic_name(name) sns_topic = SimpleMessageQueue::Notification.sns.topics.find { |t| t.name == topic_name } topic = (sns_topic) ? Topic.new(sns_topic.name, false) : nil end
find_by_full_name(full_name)
click to toggle source
# File lib/simple_message_queue/notification.rb, line 25 def find_by_full_name(full_name) sns_topic = SimpleMessageQueue::Notification.sns.topics.find { |t| t.name == full_name } topic = (sns_topic) ? Topic.new(sns_topic.name, false) : nil end
new(name, generate_topic_name=true)
click to toggle source
# File lib/simple_message_queue/notification.rb, line 44 def initialize(name, generate_topic_name=true) raise SimpleMessageQueue::ConfigurationError unless SimpleMessageQueue.configuration raise SimpleMessageQueue::EnvironmentError unless defined?(SimpleMessageQueue.configuration.environment) topic_name = (generate_topic_name) ? self.class.topic_name(name) : name @sns_topic = sns.topics.create(topic_name) end
topic_name(name)
click to toggle source
# File lib/simple_message_queue/notification.rb, line 30 def topic_name(name) if defined?(SimpleMessageQueue.configuration.sns_notification_prefix) && !SimpleMessageQueue.configuration.sns_notification_prefix.nil? topic_name = "#{SimpleMessageQueue.configuration.sns_notification_prefix}_#{name}_#{SimpleMessageQueue.configuration.environment}" else topic_name = "#{name}_#{SimpleMessageQueue.configuration.environment}" end topic_name end
Public Instance Methods
delete()
click to toggle source
# File lib/simple_message_queue/notification.rb, line 65 def delete @sns_topic.delete end
name()
click to toggle source
# File lib/simple_message_queue/notification.rb, line 52 def name @sns_topic.name end
send(message, subject=nil)
click to toggle source
# File lib/simple_message_queue/notification.rb, line 56 def send(message, subject=nil) message_hash = { topic_arn: @sns_topic.arn, message: message } message_hash[:subject] = subject if subject sns.client.publish(message_hash) end
sns()
click to toggle source
# File lib/simple_message_queue/notification.rb, line 40 def sns SimpleMessageQueue::Notification.sns end