Class: SeleniumRecord::Lookup::ClassMethods::LookupStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium_record/lookup.rb

Overview

Base class for all lookup strategies

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, attrs = {}) ⇒ LookupStrategy

Returns a new instance of LookupStrategy.

Parameters:

  • klass (SeleniumObject::Base)

    class on top over it is defined the lookup strategy

  • attrs (Hash) (defaults to: {})

    attributes used while it is the defined the lookup sequence



64
65
66
67
# File 'lib/selenium_record/lookup.rb', line 64

def initialize(klass, attrs = {})
  @klass = klass
  @attributes_blk = -> { attrs }
end

Instance Attribute Details

#lookup_attributesObject (readonly)

Returns the value of attribute lookup_attributes.



58
59
60
# File 'lib/selenium_record/lookup.rb', line 58

def lookup_attributes
  @lookup_attributes
end

Instance Method Details

#lookup_sequence(&block) ⇒ Object

Defines for the class the instance methods required for the lookup sequence. Inside the block you have access to the “lookup_attributes” specified in the constructor call

Parameters:

  • block (Block)

    defining the lookup sequence



73
74
75
76
77
78
79
80
81
# File 'lib/selenium_record/lookup.rb', line 73

def lookup_sequence(&block)
  attributes_blk = @attributes_blk
  before_lookup_blk = before_run if respond_to? :before_run
  @klass.instance_eval do
    define_method :lookup_attributes, attributes_blk
    define_method :lookup_sequence, &block
    define_method :before_lookup, before_lookup_blk if before_lookup_blk
  end
end