Sha256: 7c9607df980bc0f8f5de36903e46729d90e41d1a3d9023e26c916b00129f8e32

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

require 'cloud_powers/resource'

module Smash
  module CloudPowers
    module Synapse
      module Broadcast
        class Channel < Smash::CloudPowers::Resource

          attr_accessor :sns

          def initialize(name:, client: sns, **config)
            @sns = client
            super
          end

          # Prefers the given arn but it can make a best guess if none is given
          #
          # Returns
          # arn +String+ - arn for this resource
          def arn
            @remote_id || "arn:aws:sns:#{zfind(:region)}:#{zfind(:accound_number)}:#{name}"
          end

          def remote_id
            @remote_id || arn
          end

          # Prefers the given name but it can parse the arn to find one
          #
          # Returns
          # name +String+ - name for this resource
          def name
            @name || set_arn.split(':').last
          end

          def create_resource
            @response = sns.create_topic(name: name)
            self
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cloud_powers-1.1.1 lib/cloud_powers/synapse/broadcast/channel.rb
cloud_powers-1.1.0 lib/cloud_powers/synapse/broadcast/channel.rb
cloud_powers-1.0.1 lib/cloud_powers/synapse/broadcast/channel.rb
cloud_powers-1.0.0 lib/cloud_powers/synapse/broadcast/channel.rb