Class: Rodent::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/rodent/server.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.settingsObject

Returns the value of attribute settings



6
7
8
# File 'lib/rodent/server.rb', line 6

def settings
  @settings
end

Class Method Details

.configure(&block) ⇒ Object



8
9
10
11
# File 'lib/rodent/server.rb', line 8

def configure(&block)
  @settings ||= {}
  yield
end

.run(&block) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/rodent/server.rb', line 17

def run(&block)
  EM.run do
    AMQP.connection ||= AMQP.connect(settings[:connection])

    block.call.each(&:bind)
  end
end

.set(attr, value) ⇒ Object



13
14
15
# File 'lib/rodent/server.rb', line 13

def set(attr, value)
  settings[attr] = value
end

.stopObject



25
26
27
# File 'lib/rodent/server.rb', line 25

def stop
  AMQP.connection.close { EM.stop }
end