Class: Smash::CloudPowers::Synapse::Queue::NUMap
- Inherits:
-
Struct
- Object
- Struct
- Smash::CloudPowers::Synapse::Queue::NUMap
- 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
-
#set_name ⇒ Object
Returns the value of attribute set_name.
-
#set_url ⇒ Object
Returns the value of attribute set_url.
Instance Method Summary collapse
-
#name ⇒ Object
Gives you back the name, even if it hasn’t been set.
-
#url ⇒ Object
Gives you back the URL, even if it hasn’t been set.
Instance Attribute Details
#set_name ⇒ Object
Returns the value of attribute set_name
32 33 34 |
# File 'lib/cloud_powers/synapse/queue.rb', line 32 def set_name @set_name end |
#set_url ⇒ Object
Returns the value of attribute set_url
32 33 34 |
# File 'lib/cloud_powers/synapse/queue.rb', line 32 def set_url @set_url end |
Instance Method Details
#name ⇒ Object
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 |
#url ⇒ Object
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 |