class Awspec::Type::SnsTopic

Public Class Methods

new(topic_arn) click to toggle source
Calls superclass method Awspec::Type::ResourceBase::new
# File lib/awspec/type/sns_topic.rb, line 3
def initialize(topic_arn)
  super
  @topic_arn = topic_arn
  # lazy instantiation
  @subscriptions = nil
end

Public Instance Methods

has_subscription?(subscribed_arn) click to toggle source
# File lib/awspec/type/sns_topic.rb, line 24
def has_subscription?(subscribed_arn)
  fetch_subscriptions
  @subscriptions.key?(subscribed_arn.to_sym)
end
id() click to toggle source
# File lib/awspec/type/sns_topic.rb, line 19
def id
  # A SNS Topic doesn't have an ID...
  @id ||= resource_via_client.topic_arn if resource_via_client
end
method_missing(method_name) click to toggle source
# File lib/awspec/type/sns_topic.rb, line 36
def method_missing(method_name)
  check_existence
  # delegates the method invocation to Awspec::Helper::Finder::SnsTopic::SnsTopic class
  @resource_via_client.send method_name
end
resource_via_client() click to toggle source
# File lib/awspec/type/sns_topic.rb, line 15
def resource_via_client
  @resource_via_client ||= find_sns_topic(@topic_arn)
end
subscribed(subscribed_arn) click to toggle source
# File lib/awspec/type/sns_topic.rb, line 29
def subscribed(subscribed_arn)
  subs_key = subscribed_arn.to_sym
  fetch_subscriptions
  raise "'#{subscribed_arn}' is not a valid subscription ARN" unless @subscriptions.key?(subs_key)
  @subscriptions[subs_key]
end
subscriptions() click to toggle source
# File lib/awspec/type/sns_topic.rb, line 10
def subscriptions
  fetch_subscriptions
  @subscriptions.keys
end

Private Instance Methods

fetch_subscriptions() click to toggle source
# File lib/awspec/type/sns_topic.rb, line 44
def fetch_subscriptions
  @subscriptions = find_sns_topic_subs(@topic_arn) if @subscriptions.nil?
  raise Awspec::NoExistingResource.new(self.class, @display_name) if @subscriptions.nil?
  @subscriptions
end