Class: Freddy::Adapters::BunnyAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/freddy/adapters/bunny_adapter.rb

Defined Under Namespace

Classes: Channel, Queue

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bunny) ⇒ BunnyAdapter

Returns a new instance of BunnyAdapter.



14
15
16
# File 'lib/freddy/adapters/bunny_adapter.rb', line 14

def initialize(bunny)
  @bunny = bunny
end

Class Method Details

.connect(config) ⇒ Object



8
9
10
11
12
# File 'lib/freddy/adapters/bunny_adapter.rb', line 8

def self.connect(config)
  bunny = Bunny.new(config)
  bunny.start
  new(bunny)
end

Instance Method Details

#closeObject



24
25
26
# File 'lib/freddy/adapters/bunny_adapter.rb', line 24

def close
  @bunny.close
end

#create_channel(prefetch: nil) ⇒ Object



18
19
20
21
22
# File 'lib/freddy/adapters/bunny_adapter.rb', line 18

def create_channel(prefetch: nil)
  bunny_channel = @bunny.create_channel
  bunny_channel.prefetch(prefetch) if prefetch
  Channel.new(bunny_channel)
end