Class: Shoryuken::Topic

Inherits:
Object
  • Object
show all
Defined in:
lib/shoryuken/topic.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, sns) ⇒ Topic

Returns a new instance of Topic


3
4
5
# File 'lib/shoryuken/topic.rb', line 3

def initialize(name, sns)
  @name, @sns = name, sns
end

Instance Method Details

#arnObject


7
8
9
# File 'lib/shoryuken/topic.rb', line 7

def arn
  @arn ||= Client.sns_arn.new(@name).to_s
end

#send_message(body, options = {}) ⇒ Object


11
12
13
14
15
# File 'lib/shoryuken/topic.rb', line 11

def send_message(body, options = {})
  body = JSON.dump(body) if body.is_a?(Hash)

  @sns.publish(topic_arn: arn, message: body)
end