Class: Factor::Runtime::ServiceAddress
- Inherits:
-
Array
- Object
- Array
- Factor::Runtime::ServiceAddress
- Defined in:
- lib/runtime/service_address.rb
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(service_ref) ⇒ ServiceAddress
constructor
A new instance of ServiceAddress.
- #namespace ⇒ Object
- #service ⇒ Object
- #to_s ⇒ Object
- #workflow? ⇒ Boolean
- #workflow_address ⇒ Object
Constructor Details
#initialize(service_ref) ⇒ ServiceAddress
Returns a new instance of ServiceAddress.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/runtime/service_address.rb', line 4 def initialize(service_ref) if service_ref.is_a?(String) service_map = service_ref.split('::') raise ArgumentError, 'Address must not be empty' if service_ref.empty? raise ArgumentError, 'Address must contain at least one value' unless service_map.count > 0 raise ArgumentError, 'Address must contain at least one value' unless service_map.all?{|i| !i.empty?} super service_map elsif service_ref.is_a?(ServiceAddress) || service_ref.is_a?(Array) raise ArgumentError, 'All elements in array must be a string' unless service_ref.all?{|i| i.is_a?(String)} super service_ref else raise ArgumentError, 'Address must be a String, Array, or ServiceAddress' end end |
Instance Method Details
#id ⇒ Object
32 33 34 |
# File 'lib/runtime/service_address.rb', line 32 def id self.last end |
#namespace ⇒ Object
27 28 29 30 |
# File 'lib/runtime/service_address.rb', line 27 def namespace raise ArgumentError, 'Address must contain at least two parts' unless self.count >= 2 self[0..-2].map{|k| k.to_sym} end |
#service ⇒ Object
23 24 25 |
# File 'lib/runtime/service_address.rb', line 23 def service self.first end |
#to_s ⇒ Object
36 37 38 |
# File 'lib/runtime/service_address.rb', line 36 def to_s self.join('::') end |
#workflow? ⇒ Boolean
19 20 21 |
# File 'lib/runtime/service_address.rb', line 19 def workflow? self.service == 'workflow' end |
#workflow_address ⇒ Object
40 41 42 43 |
# File 'lib/runtime/service_address.rb', line 40 def workflow_address workflow_service_map = self[1..-1] ServiceAddress.new workflow_service_map end |