Sha256: 827ed9e386ff34e9ed22e8ee2236dc823f130b50b7461eccfbb4b3de42cbaf83

Contents?: true

Size: 698 Bytes

Versions: 3

Compression:

Stored size: 698 Bytes

Contents

require 'drb'
require 'drb/acl'

# The God::Server oversees the DRb server which dishes out info on this God daemon.

module God

  class Server
    attr_reader :host, :port

    def initialize(host = nil, port = nil, allow = [])
      @host = host
      @port = port
      @acl = %w{deny all} + allow.inject([]) { |acc, a| acc + ['allow', a] }
      puts "Starting on #{@host}:#{@port}"
      start
    end

    def ping
      true
    end
    
    def method_missing(*args, &block)
      God.send(*args, &block)
    end

    private

    def start
      acl = ACL.new(@acl)
      DRb.install_acl(acl)
      
      @drb ||= DRb.start_service("druby://#{@host}:#{@port}", self) 
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
god-0.4.1 lib/god/server.rb
god-0.4.3 lib/god/server.rb
god-0.4.0 lib/god/server.rb