Class: Crabfarm::ForkedState

Inherits:
Delegator
  • Object
show all
Defined in:
lib/crabfarm/forked_state.rb

Instance Method Summary collapse

Constructor Details

#initialize(_state, _name, _mutex) ⇒ ForkedState

Returns a new instance of ForkedState.



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

def initialize(_state, _name, _mutex)
  @state = _state
  @name = _name
  @mutex = _mutex

  super @state
end

Instance Method Details

#__getobj__Object



30
31
32
# File 'lib/crabfarm/forked_state.rb', line 30

def __getobj__
  @state
end

#__setobj__(obj) ⇒ Object



34
35
36
# File 'lib/crabfarm/forked_state.rb', line 34

def __setobj__(obj)
  @state = obj
end

#browserObject



16
17
18
# File 'lib/crabfarm/forked_state.rb', line 16

def browser
  @browser ||= @state.browser(@name)
end

#driverObject



12
13
14
# File 'lib/crabfarm/forked_state.rb', line 12

def driver
  @driver ||= @state.driver(@name)
end

#lock_outputObject



24
25
26
27
28
# File 'lib/crabfarm/forked_state.rb', line 24

def lock_output
  @mutex.synchronize {
    yield @state.output
  }
end

#outputObject



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

def output
  raise ScriptError.new 'Use lock_output to access output in forked states'
end