Class: Crabfarm::CrabtrapContext

Inherits:
Context
  • Object
show all
Defined in:
lib/crabfarm/crabtrap_context.rb

Instance Attribute Summary collapse

Attributes inherited from Context

#pool, #store

Instance Method Summary collapse

Methods inherited from Context

#loaded?, #prepare, #release, #reset

Constructor Details

#initialize(_mode = :pass, _path = nil) ⇒ CrabtrapContext

Returns a new instance of CrabtrapContext.



7
8
9
10
# File 'lib/crabfarm/crabtrap_context.rb', line 7

def initialize(_mode=:pass, _path=nil)
  @mode = _mode
  @path = _path
end

Instance Attribute Details

#modeObject

Returns the value of attribute mode.



5
6
7
# File 'lib/crabfarm/crabtrap_context.rb', line 5

def mode
  @mode
end

Instance Method Details

#capture(_path) ⇒ Object



20
21
22
23
24
# File 'lib/crabfarm/crabtrap_context.rb', line 20

def capture(_path)
  @mode = :capture
  @path = _path
  restart
end

#pass_throughObject



12
13
14
15
16
17
18
# File 'lib/crabfarm/crabtrap_context.rb', line 12

def pass_through
  if not loaded? or @mode != :pass
    @mode = :pass
    @path = nil
    restart
  end
end

#replay(_path) ⇒ Object



26
27
28
29
30
# File 'lib/crabfarm/crabtrap_context.rb', line 26

def replay(_path)
  @mode = :replay
  @path = _path
  restart
end

#restartObject



32
33
34
35
36
37
38
39
# File 'lib/crabfarm/crabtrap_context.rb', line 32

def restart
  if not loaded?
    prepare
  else
    stop_daemon
    start_daemon
  end
end