Class: Smash::CloudPowers::Synapse::Broadcast::Channel

Inherits:
Struct
  • Object
show all
Includes:
Zenv
Defined in:
lib/cloud_powers/synapse/broadcast/broadcast.rb,
lib/cloud_powers/synapse/broadcast/channel.rb

Overview

A simple Struct to bind the name with the arn of the topic

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Zenv

#env_vars, #file_tree_search, #i_vars, #project_root, #project_root=, #system_vars, #zfind

Methods included from Helpers

#create_logger, #log_file, #logger

Methods included from PathHelp

#job_exist?, #job_home, #job_path, #job_require_path

Methods included from LogicHelp

#attr_map, #called_from, #instance_attr_accessor, #smart_retry, #update_message_body

Methods included from LangHelp

#deep_modify_keys_with, #find_and_remove, #format_error_message, #from_json, #modify_keys_with, #to_basic_hash, #to_camel, #to_hyph, #to_i_var, #to_pascal, #to_ruby_file_name, #to_snake, #valid_json?, #valid_url?

Constructor Details

#initialize(name:, client: sns, **config) ⇒ Channel



11
12
13
14
# File 'lib/cloud_powers/synapse/broadcast/channel.rb', line 11

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

Instance Attribute Details

#set_arnObject

Returns the value of attribute set_arn



10
11
12
# File 'lib/cloud_powers/synapse/broadcast/broadcast.rb', line 10

def set_arn
  @set_arn
end

#set_endpointObject

Returns the value of attribute set_endpoint



10
11
12
# File 'lib/cloud_powers/synapse/broadcast/broadcast.rb', line 10

def set_endpoint
  @set_endpoint
end

#set_nameObject

Returns the value of attribute set_name



10
11
12
# File 'lib/cloud_powers/synapse/broadcast/broadcast.rb', line 10

def set_name
  @set_name
end

#snsObject

Returns the value of attribute sns.



9
10
11
# File 'lib/cloud_powers/synapse/broadcast/channel.rb', line 9

def sns
  @sns
end

Instance Method Details

#arnObject

Prefers the given arn but it can make a best guess if none is given

Returns arn String - arn for this resource



20
21
22
# File 'lib/cloud_powers/synapse/broadcast/channel.rb', line 20

def arn
  @remote_id || "arn:aws:sns:#{zfind(:region)}:#{zfind(:accound_number)}:#{name}"
end

#create_resourceObject



36
37
38
39
# File 'lib/cloud_powers/synapse/broadcast/channel.rb', line 36

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

#nameObject

Prefers the given name but it can parse the arn to find one

Returns name String - name for this resource



32
33
34
# File 'lib/cloud_powers/synapse/broadcast/channel.rb', line 32

def name
  @name || set_arn.split(':').last
end

#remote_idObject



24
25
26
# File 'lib/cloud_powers/synapse/broadcast/channel.rb', line 24

def remote_id
  @remote_id || arn
end