Module: GorgonBunny::Compatibility

Included in:
Exchange, Queue
Defined in:
lib/gorgon_bunny/lib/gorgon_bunny/compatibility.rb

Overview

Helper methods necessary to stay mostly backwards-compatible with legacy (0.7.x, 0.8.x) GorgonBunny releases that hide channels completely from the API.

Instance Method Summary collapse

Instance Method Details

#channel_from(channel_or_connection) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/gorgon_bunny/lib/gorgon_bunny/compatibility.rb', line 13

def channel_from(channel_or_connection)
  # GorgonBunny 0.8.x and earlier completely hide channels from the API. So, queues and exchanges are
  # instantiated with a "GorgonBunny object", which is a session. This function coerces two types of input to a
  # channel.
  if channel_or_connection.is_a?(GorgonBunny::Session)
    channel_or_connection.default_channel
  else
    channel_or_connection
  end
end