Class: Crabfarm::Context
- Inherits:
-
Object
- Object
- Crabfarm::Context
- Extended by:
- Forwardable
- Defined in:
- lib/crabfarm/context.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize ⇒ Context
constructor
A new instance of Context.
- #load ⇒ Object
- #release ⇒ Object
- #reset ⇒ Object
- #run_state(_name, _params = {}) ⇒ Object
Constructor Details
#initialize ⇒ Context
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 Method Details
#load ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/crabfarm/context.rb', line 14 def load unless @loaded init_phantom_if_required @pool = DriverBucketPool.new build_driver_factory @loaded = true end end |
#release ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/crabfarm/context.rb', line 35 def release if @loaded @pool.release @phantom.stop unless @phantom.nil? @loaded = false end end |
#reset ⇒ Object
29 30 31 32 33 |
# File 'lib/crabfarm/context.rb', line 29 def reset load @store.reset @pool.reset end |
#run_state(_name, _params = {}) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/crabfarm/context.rb', line 22 def run_state(_name, _params={}) load state = LoaderService.load_state(_name).new @pool, @store, _params state.crawl state end |