Class: Crabfarm::Context

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/crabfarm/context.rb

Direct Known Subclasses

CrabtrapContext

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeContext

Returns a new instance of Context.



9
10
11
12
# File 'lib/crabfarm/context.rb', line 9

def initialize
  @store = StateStore.new
  @loaded = false
end

Instance Attribute Details

#httpObject

Returns the value of attribute http.



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

def http
  @http
end

#poolObject

Returns the value of attribute pool.



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

def pool
  @pool
end

#storeObject

Returns the value of attribute store.



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

def store
  @store
end

Instance Method Details

#loadObject



14
15
16
17
18
19
# File 'lib/crabfarm/context.rb', line 14

def load
  init_phantom_if_required
  init_driver_pool
  init_http_client
  @loaded = true
end

#releaseObject



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

def release
  release_driver_pool
  release_phantom
  @loaded = false
end

#resetObject



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

def reset
  @store.reset
  @pool.reset unless @pool.nil?
end