Sha256: 3068b9cc2f04d536fc3885459992a9ff17c8f4866a6a42ce31ff413c4d5b7491

Contents?: true

Size: 475 Bytes

Versions: 10

Compression:

Stored size: 475 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
      result = sns.create_topic(@topic_id)
      body = result.body
      arn = body.fetch('TopicArn') { raise TopicCreatorError.new("No TopicArn returned from SNS") }
      Topic.new(arn)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
propono-0.5.6 lib/propono/services/topic_creator.rb
propono-0.5.5 lib/propono/services/topic_creator.rb
propono-0.5.4 lib/propono/services/topic_creator.rb
propono-0.5.3 lib/propono/services/topic_creator.rb
propono-0.5.2 lib/propono/services/topic_creator.rb
propono-0.5.1 lib/propono/services/topic_creator.rb
propono-0.5.0 lib/propono/services/topic_creator.rb
propono-0.4.0 lib/propono/services/topic_creator.rb
propono-0.3.0 lib/propono/services/topic_creator.rb
propono-0.2.0 lib/propono/services/topic_creator.rb