Class: Carrot
- Inherits:
-
Object
show all
- Defined in:
- lib/secure_carrot.rb,
lib/secure_carrot.rb,
lib/secure_carrot.rb
Overview
– convenience wrapper (read: HACK) for thread-local Carrot object
Defined Under Namespace
Modules: AMQP
Classes: Error
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(opts = {}) ⇒ Carrot
Returns a new instance of Carrot.
31
32
33
|
# File 'lib/secure_carrot.rb', line 31
def initialize(opts = {})
@opts = opts
end
|
Class Attribute Details
.logging ⇒ Object
Returns the value of attribute logging.
24
25
26
|
# File 'lib/secure_carrot.rb', line 24
def logging
@logging
end
|
Class Method Details
.default ⇒ Object
81
82
83
84
|
# File 'lib/secure_carrot.rb', line 81
def Carrot.default
Thread.current[:carrot] ||= Carrot.new
end
|
.logging? ⇒ Boolean
26
27
28
|
# File 'lib/secure_carrot.rb', line 26
def self.logging?
@logging
end
|
.method_missing(meth, *args, &blk) ⇒ Object
Allows for calls to all Carrot instance methods. This implicitly calls Carrot.new so that a new channel is allocated for subsequent operations.
88
89
90
|
# File 'lib/secure_carrot.rb', line 88
def Carrot.method_missing(meth, *args, &blk)
Carrot.default.__send__(meth, *args, &blk)
end
|
Instance Method Details
#direct(name = 'amq.direct', opts = {}) ⇒ Object
53
54
55
|
# File 'lib/secure_carrot.rb', line 53
def direct(name = 'amq.direct', opts = {})
exchanges[name] ||= AMQP::Exchange.new(self, :direct, name, opts)
end
|
#exchanges ⇒ Object
65
66
67
|
# File 'lib/secure_carrot.rb', line 65
def exchanges
@exchanges ||= {}
end
|
61
62
63
|
# File 'lib/secure_carrot.rb', line 61
def (name = 'amq.match', opts = {})
exchanges[name] ||= AMQP::Exchange.new(self, :headers, name, opts)
end
|
#queue(name, opts = {}) ⇒ Object
35
36
37
|
# File 'lib/secure_carrot.rb', line 35
def queue(name, opts = {})
queues[name] ||= AMQP::Queue.new(self, name, opts)
end
|
#queues ⇒ Object
49
50
51
|
# File 'lib/secure_carrot.rb', line 49
def queues
@queues ||= {}
end
|
#server ⇒ Object
39
40
41
|
# File 'lib/secure_carrot.rb', line 39
def server
@server ||= AMQP::Server.new(@opts)
end
|
#stop ⇒ Object
Also known as:
reset
43
44
45
46
|
# File 'lib/secure_carrot.rb', line 43
def stop
server.close
@server = nil
end
|
#topic(name = 'amq.topic', opts = {}) ⇒ Object
57
58
59
|
# File 'lib/secure_carrot.rb', line 57
def topic(name = 'amq.topic', opts = {})
exchanges[name] ||= AMQP::Exchange.new(self, :topic, name, opts)
end
|