Class: Stapfen::Destination
- Inherits:
-
Object
- Object
- Stapfen::Destination
- Defined in:
- lib/stapfen/destination.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
-
.from_string(name) ⇒ Stapfen::Destination
Create a Destination from the given string.
Instance Method Summary collapse
- #as_jms ⇒ Object
- #as_kafka ⇒ Object
- #as_stomp ⇒ Object
- #jms_opts ⇒ Object
- #queue? ⇒ Boolean
- #topic? ⇒ Boolean
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/stapfen/destination.rb', line 3 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/stapfen/destination.rb', line 3 def type @type end |
Class Method Details
.from_string(name) ⇒ Stapfen::Destination
Create a Stapfen::Destination from the given string
51 52 53 54 55 56 57 |
# File 'lib/stapfen/destination.rb', line 51 def self.from_string(name) destination = self.new pieces = name.split('/') destination.type = pieces[1].to_sym destination.name = pieces[2 .. -1].join('/') return destination end |
Instance Method Details
#as_jms ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/stapfen/destination.rb', line 23 def as_jms if queue? return "queue://#{@name}" end if topic? return "topic://#{@name}" end end |
#as_kafka ⇒ Object
43 44 45 |
# File 'lib/stapfen/destination.rb', line 43 def as_kafka return name end |
#as_stomp ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/stapfen/destination.rb', line 13 def as_stomp if queue? return "/queue/#{@name}" end if topic? return "/topic/#{@name}" end end |
#jms_opts ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/stapfen/destination.rb', line 33 def jms_opts if queue? return {:queue_name => name} end if topic? return {:topic_name => name} end end |
#queue? ⇒ Boolean
5 6 7 |
# File 'lib/stapfen/destination.rb', line 5 def queue? @type == :queue end |
#topic? ⇒ Boolean
9 10 11 |
# File 'lib/stapfen/destination.rb', line 9 def topic? @type == :topic end |