Class: Domkey::View::PageObjectCollection

Inherits:
Object
  • Object
show all
Includes:
Widgetry::Package, Enumerable
Defined in:
lib/domkey/view/page_object_collection.rb

Overview

PageObjectCollection see PageObject for detailes. Compose PageObjectCollection with package and container

What is a container? see PageObject container

What is package? see PageObject package except the following: package can be one of the following:

- definition of watir elements collection i.e. `-> { text_fields(:class, /^foo/)}`
- a pageobject i.e. previously instantiated definition watir elements collection
- hash where key defines subelement and value a definition or pageobject

Usage: Clients would not usually instantate this class. A client class which acts as a View would use a :doms factory method to create PageObjectCollection TODO Example:

Direct Known Subclasses

OptionSelectableGroup

Instance Attribute Summary

Attributes included from Widgetry::Package

#container, #package

Instance Method Summary collapse

Methods included from Widgetry::Package

#element, #initialize

Instance Method Details

#[](idx) ⇒ PageObject, Hash{Symbol => PageObjectCollection}

Parameters:

  • (Fixnum)

Returns:



35
36
37
# File 'lib/domkey/view/page_object_collection.rb', line 35

def [] idx
  to_a[idx]
end

#each(&blk) ⇒ PageObject, Hash{Symbol => PageObjectCollection}

Returns:



25
26
27
28
29
30
31
# File 'lib/domkey/view/page_object_collection.rb', line 25

def each(&blk)
  if package.respond_to?(:each_pair)
    package.map { |k, v| [k, PageObjectCollection.new(lambda { v }, @container)] }.each { |k, v| yield Hash[k, v] }
  else
    instantiator.each { |e| yield PageObject.new(lambda { e }, @container) }
  end
end