Class: Crabfarm::DriverBucket

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_session_id, _factory) ⇒ DriverBucket

Returns a new instance of DriverBucket.



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

def initialize(_session_id, _factory)
  @session_id = _session_id
  @factory = _factory
  @driver = nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)



37
38
39
# File 'lib/crabfarm/driver_bucket.rb', line 37

def method_missing(method, *args, &block)
  original.__send__(method, *args, &block)
end

Instance Attribute Details

#session_idObject (readonly)

Returns the value of attribute session_id.



4
5
6
# File 'lib/crabfarm/driver_bucket.rb', line 4

def session_id
  @session_id
end

Instance Method Details

#originalObject



17
18
19
# File 'lib/crabfarm/driver_bucket.rb', line 17

def original
  @driver ||= @factory.build_driver(@session_id)
end

#resetObject



21
22
23
24
25
26
27
# File 'lib/crabfarm/driver_bucket.rb', line 21

def reset
  if @driver
    @driver.quit rescue nil
    @driver = nil
  end
  self
end

#respond_to?(symbol, include_priv = false) ⇒ Boolean

forward every missing method to actual driver

Returns:

  • (Boolean)


31
32
33
# File 'lib/crabfarm/driver_bucket.rb', line 31

def respond_to?(symbol, include_priv=false)
  original.respond_to?(symbol, include_priv)
end

#setup(_factory) ⇒ Object



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

def setup(_factory)
  reset
  @factory = _factory
end