Class: StackMaster::SnsTopicFinder
- Inherits:
-
Object
- Object
- StackMaster::SnsTopicFinder
- Defined in:
- lib/stack_master/sns_topic_finder.rb
Constant Summary collapse
- TopicNotFound =
Class.new(StandardError)
Instance Method Summary collapse
- #find(reference) ⇒ Object
-
#initialize(region) ⇒ SnsTopicFinder
constructor
A new instance of SnsTopicFinder.
Constructor Details
#initialize(region) ⇒ SnsTopicFinder
Returns a new instance of SnsTopicFinder.
5 6 7 |
# File 'lib/stack_master/sns_topic_finder.rb', line 5 def initialize(region) @resource = Aws::SNS::Resource.new({ region: region }) end |
Instance Method Details
#find(reference) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/stack_master/sns_topic_finder.rb', line 9 def find(reference) raise ArgumentError, 'SNS topic references must be non-empty strings' unless reference.is_a?(String) && !reference.empty? topic = @resource.topics.detect { |t| topic_name_from_arn(t.arn) == reference } raise TopicNotFound, "No topic with name #{reference} found" unless topic topic.arn end |