Class: BunnyHair::Exchange
- Inherits:
-
Object
- Object
- BunnyHair::Exchange
- Defined in:
- lib/bunny_hair/exchange.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #channel ⇒ Object
-
#initialize(connection, type, name, options = {}) ⇒ Exchange
constructor
A new instance of Exchange.
- #method_missing(method, *args) ⇒ Object
- #publish(message, options = {}) ⇒ Object
- #queues ⇒ Object
Constructor Details
#initialize(connection, type, name, options = {}) ⇒ Exchange
Returns a new instance of Exchange.
7 8 9 10 11 12 |
# File 'lib/bunny_hair/exchange.rb', line 7 def initialize(connection, type, name, ={}) @connection = connection @name = name @type = type @options = end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/bunny_hair/exchange.rb', line 28 def method_missing(method, *args) method_name = method.to_s is_predicate = false if method_name =~ /^(.*)\?$/ return !![method_name.gsub('?', '').to_sym] end super end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
5 6 7 |
# File 'lib/bunny_hair/exchange.rb', line 5 def connection @connection end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/bunny_hair/exchange.rb', line 5 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/bunny_hair/exchange.rb', line 5 def @options end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/bunny_hair/exchange.rb', line 5 def type @type end |
Instance Method Details
#publish(message, options = {}) ⇒ Object
22 23 24 25 26 |
# File 'lib/bunny_hair/exchange.rb', line 22 def publish(, ={}) queues.each do |queue| queue.receive(OpenStruct.new, OpenStruct.new, ) end end |
#queues ⇒ Object
14 15 16 |
# File 'lib/bunny_hair/exchange.rb', line 14 def queues @queues ||= [] end |