Class: Crabfarm::BaseNavigator
- Inherits:
-
Object
- Object
- Crabfarm::BaseNavigator
- Includes:
- Assertion::Context, Base, Live::Interactable
- Defined in:
- lib/crabfarm/base_navigator.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #browser(_name = nil) ⇒ Object
- #fork_each(_enumerator, &_block) ⇒ Object
-
#initialize(_context, _params) ⇒ BaseNavigator
constructor
A new instance of BaseNavigator.
- #navigate(_name, _params = {}) ⇒ Object (also: #nav)
- #reduce(_target = nil, _options = {}) ⇒ Object (also: #reduce_with_defaults)
- #run ⇒ Object
- #session ⇒ Object
Methods included from Live::Interactable
Methods included from Assertion::Context
Methods included from Base
Constructor Details
#initialize(_context, _params) ⇒ BaseNavigator
Returns a new instance of BaseNavigator.
15 16 17 18 |
# File 'lib/crabfarm/base_navigator.rb', line 15 def initialize(_context, _params) @context = _context @params = _params end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
13 14 15 |
# File 'lib/crabfarm/base_navigator.rb', line 13 def params @params end |
Instance Method Details
#browser(_name = nil) ⇒ Object
30 31 32 |
# File 'lib/crabfarm/base_navigator.rb', line 30 def browser(_name=nil) @context.pool.driver(_name) end |
#fork_each(_enumerator, &_block) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/crabfarm/base_navigator.rb', line 51 def fork_each(_enumerator, &_block) session_id = 0 mutex = Mutex.new ths = _enumerator.map do |value| session_id += 1 ("th_session_#{session_id}", value, _block, mutex) end ThreadsWait.all_waits(*ths) end |
#navigate(_name, _params = {}) ⇒ Object Also known as:
24 25 26 |
# File 'lib/crabfarm/base_navigator.rb', line 24 def navigate(_name, _params={}) TransitionService.transition(@context, _name, params.merge(_params)) end |
#reduce(_target = nil, _options = {}) ⇒ Object Also known as: reduce_with_defaults
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/crabfarm/base_navigator.rb', line 38 def reduce(_target=nil, ={}) if _target.is_a? Hash = _target _target = browser elsif _target.nil? _target = browser end reduce_using(.delete(:using) || self.class.name, _target, ) end |
#run ⇒ Object
34 35 36 |
# File 'lib/crabfarm/base_navigator.rb', line 34 def run raise NotImplementedError.new end |
#session ⇒ Object
20 21 22 |
# File 'lib/crabfarm/base_navigator.rb', line 20 def session @context.store end |