Sha256: 515b9106f22d4f44c7c5802eae9d7aa4e66689250e8dd4eb378e7bbfa8bfb4f8

Contents?: true

Size: 474 Bytes

Versions: 1

Compression:

Stored size: 474 Bytes

Contents

module Propono
  class TopicCreatorError < Exception
  end

  class TopicCreator
    include Sns

    def self.find_or_create(topic_id)
      new(topic_id).find_or_create
    end

    def initialize(topic_id)
      @topic_id = topic_id
    end

    def find_or_create
      create_topic_result = sns.create_topic(@topic_id)
      body = create_topic_result.body
      body.fetch('TopicArn') { raise TopicCreatorError.new("No TopicArn returned from SNS") }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
propono-0.0.1 lib/propono/topic_creator.rb