Module: Watir::AttributeHelper

Included in:
Element
Defined in:
lib/watir-webdriver/attribute_helper.rb

Overview

Extended by Element, provides methods for defining attributes on the element classes.

Instance Method Summary collapse

Instance Method Details

#attribute(type, method, attr) ⇒ type

YARD macro to generated friendly documentation for attributes.

Returns:

  • (type)

    value of attr property



40
41
42
43
# File 'lib/watir-webdriver/attribute_helper.rb', line 40

def attribute(type, method, attr)
  typed_attributes[type] << [method, attr]
  define_attribute(type, method, attr)
end

#attribute_listObject Also known as: attributes



21
22
23
24
25
26
27
28
# File 'lib/watir-webdriver/attribute_helper.rb', line 21

def attribute_list
  @attribute_list ||= (
    list = typed_attributes.values.flatten
    list += ancestors[1..-1].map do |e|
      e.attribute_list if e.respond_to?(:attribute_list)
    end.compact.flatten
  ).uniq
end

#inherit_attributes_from(kls) ⇒ Object



11
12
13
14
15
# File 'lib/watir-webdriver/attribute_helper.rb', line 11

def inherit_attributes_from(kls)
  kls.typed_attributes.each do |type, attrs|
    attrs.each { |method, attr| attribute type, method, attr }
  end
end

#methodtype

YARD macro to generated friendly documentation for attributes.

Returns:

  • (type)

    value of attr property



40
41
42
43
# File 'lib/watir-webdriver/attribute_helper.rb', line 40

def attribute(type, method, attr)
  typed_attributes[type] << [method, attr]
  define_attribute(type, method, attr)
end

#typed_attributesObject



17
18
19
# File 'lib/watir-webdriver/attribute_helper.rb', line 17

def typed_attributes
  @typed_attributes ||= Hash.new { |hash, type| hash[type] = []  }
end