Class: Sns

Inherits:
Message show all
Defined in:
lib/cryo/message/sns.rb

Instance Method Summary collapse

Methods inherited from Message

create, #get, #put

Constructor Details

#initialize(opts = {}) ⇒ Sns

Returns a new instance of Sns.



4
5
6
7
8
9
# File 'lib/cryo/message/sns.rb', line 4

def initialize(opts={})
  AWS.config(:access_key_id => opts[:aws_access_key], 
             :secret_access_key => opts[:aws_secret_key])
  @sns = AWS::SNS::Client.new
  @topic = opts[:topic] || opts[:topic_arn]
end

Instance Method Details

#send(opts = {}) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/cryo/message/sns.rb', line 12

def send(opts={})
  @sns.publish({
                 :message => opts[:message],
                 :subject => opts[:subject],
                 :topic_arn => @topic
               })
end