Sha256: 2746688463980831f81248c24c3f93d9834433c32ad7f2539e28f32b862dd502

Contents?: true

Size: 490 Bytes

Versions: 5

Compression:

Stored size: 490 Bytes

Contents

require 'amqp'

module Rodent
  class Server
    class << self
      attr_accessor :settings

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

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

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

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

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rodent-0.0.7 lib/rodent/server.rb
rodent-0.0.6 lib/rodent/server.rb
rodent-0.0.4 lib/rodent/server.rb
rodent-0.0.3 lib/rodent/server.rb
rodent-0.0.2 lib/rodent/server.rb