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

- (type) attribute(type, method, attr)

YARD macro to generated friendly documentation for attributes.



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

- (Object) attribute_list 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

- (Object) inherit_attributes_from(kls)



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

- (type) method

YARD macro to generated friendly documentation for attributes.



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

- (Object) typed_attributes



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

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