Class: Smash::CloudPowers::Synapse::Queue::NUMap

Inherits:
Struct
  • Object
show all
Defined in:
lib/cloud_powers/synapse/queue.rb

Overview

A simple Struct that acts as a Name to URL map

Parameters

  • :set_name String (optional) - An optional name. It should be the same name as the the QueueResource and/or Queue you’re working with, or else this Struct isn’t that useful

  • :set_url String (optional) - An optional URL. It should be the same URL as the the QueueResource and/or Queue you’re working with, or else this Struct isn’t that useful

Attributes

  • name String - the :set_name or parse the #address() for the name

  • url String - the :set_url or add the name to the end of a best guess at the URL

Example

name_url_map = NUMap.new(nil, 'https://sqs.us-west-53.amazonaws.com/001101010010/fooBar')
name_url_map.name
# => 'fooBar'

# and now in reverse
url_name_map = NUMap.new('snargleBargle')
url_name_map.address
# => 'https://sqs.us-west-53.amazonaws.com/001101010010/snargleBargle'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#set_nameObject

Returns the value of attribute set_name

Returns:

  • (Object)

    the current value of set_name



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

def set_name
  @set_name
end

#set_urlObject

Returns the value of attribute set_url

Returns:

  • (Object)

    the current value of set_url



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

def set_url
  @set_url
end

Instance Method Details

#nameObject

Gives you back the name, even if it hasn’t been set

Returns String



37
38
39
# File 'lib/cloud_powers/synapse/queue.rb', line 37

def name
  set_name || url.split('/').last # Queue names are last in the URL path
end

#urlObject

Gives you back the URL, even if it hasn’t been set

Returns String



45
46
47
# File 'lib/cloud_powers/synapse/queue.rb', line 45

def url
  set_url || Smash::CloudPowers::Synapse::Queue::Board.new(name: name).best_guess_address
end