Class: Stapfen::Destination

Inherits:
Object
  • Object
show all
Defined in:
lib/stapfen/destination.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/stapfen/destination.rb', line 3

def name
  @name
end

#typeObject

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

Parameters:

  • name (String)

Returns:



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_jmsObject



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_kafkaObject



43
44
45
# File 'lib/stapfen/destination.rb', line 43

def as_kafka
  return name
end

#as_stompObject



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_optsObject



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

Returns:

  • (Boolean)


5
6
7
# File 'lib/stapfen/destination.rb', line 5

def queue?
  @type == :queue
end

#topic?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/stapfen/destination.rb', line 9

def topic?
  @type == :topic
end