Module: RedRock

Defined in:
lib/redrock.rb,
lib/redrock/server.rb

Defined Under Namespace

Classes: Server

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



28
29
30
31
32
# File 'lib/redrock.rb', line 28

def method_missing name, *args, &block
  super unless Server.instance.respond_to? name
  start unless @server_thread
  Server.instance.send name, *args, &block
end

Instance Method Details

#allow_net_connect!Object



20
21
22
# File 'lib/redrock.rb', line 20

def allow_net_connect!
  raise "RedRock does not support allowing real connections"
end

#disable_net_connect!Object



24
25
26
# File 'lib/redrock.rb', line 24

def disable_net_connect!
  raise "RedRock does not support disabling real connections"
end

#start(port = 4242) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/redrock.rb', line 4

def start port = 4242
  raise "RedRock is already running" if @server_thread
  @server_thread = Thread.new do
    Thin::Server.start('0.0.0.0', port) do
      run RedRock::Server.instance
    end
  end
end

#stopObject



13
14
15
16
17
18
# File 'lib/redrock.rb', line 13

def stop
  if @server_thread
    @server_thread.exit
    @server_thread = nil
  end
end