Module: SitePrism::ElementContainer::ClassMethods
- Defined in:
- lib/site_prism/element_container.rb
Instance Attribute Summary collapse
-
#expected_items ⇒ Object
readonly
Returns the value of attribute expected_items.
-
#mapped_items ⇒ Object
readonly
Returns the value of attribute mapped_items.
Instance Method Summary collapse
- #add_to_mapped_items(item) ⇒ Object
- #element(element_name, *find_args) ⇒ Object
- #elements(collection_name, *find_args) ⇒ Object (also: #collection)
- #expected_elements(*elements) ⇒ Object
- #iframe(iframe_name, iframe_page_class, *args) ⇒ Object
- #section(section_name, *args, &block) ⇒ Object
- #sections(section_collection_name, *args, &block) ⇒ Object
Instance Attribute Details
#expected_items ⇒ Object (readonly)
Returns the value of attribute expected_items.
42 43 44 |
# File 'lib/site_prism/element_container.rb', line 42 def expected_items @expected_items end |
#mapped_items ⇒ Object (readonly)
Returns the value of attribute mapped_items.
42 43 44 |
# File 'lib/site_prism/element_container.rb', line 42 def mapped_items @mapped_items end |
Instance Method Details
#add_to_mapped_items(item) ⇒ Object
100 101 102 103 |
# File 'lib/site_prism/element_container.rb', line 100 def add_to_mapped_items(item) @mapped_items ||= [] @mapped_items << item end |
#element(element_name, *find_args) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/site_prism/element_container.rb', line 44 def element(element_name, *find_args) build(element_name, *find_args) do define_method(element_name.to_s) do |*runtime_args, &element_block| raise_if_block(self, element_name.to_s, !element_block.nil?) find_first(*merge_args(find_args, runtime_args)) end end end |
#elements(collection_name, *find_args) ⇒ Object Also known as: collection
53 54 55 56 57 58 59 60 |
# File 'lib/site_prism/element_container.rb', line 53 def elements(collection_name, *find_args) build(collection_name, *find_args) do define_method(collection_name.to_s) do |*runtime_args, &element_block| raise_if_block(self, collection_name.to_s, !element_block.nil?) find_all(*merge_args(find_args, runtime_args)) end end end |
#expected_elements(*elements) ⇒ Object
63 64 65 |
# File 'lib/site_prism/element_container.rb', line 63 def expected_elements(*elements) @expected_items = elements end |
#iframe(iframe_name, iframe_page_class, *args) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/site_prism/element_container.rb', line 88 def iframe(iframe_name, iframe_page_class, *args) element_find_args = deduce_iframe_element_find_args(args) scope_find_args = deduce_iframe_scope_find_args(args) add_to_mapped_items(iframe_name) add_iframe_helper_methods(iframe_name, *element_find_args) define_method(iframe_name) do |&block| within_frame(*scope_find_args) do block.call iframe_page_class.new end end end |
#section(section_name, *args, &block) ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'lib/site_prism/element_container.rb', line 67 def section(section_name, *args, &block) section_class, find_args = (args, &block) build(section_name, *find_args) do define_method section_name do |*runtime_args, &runtime_block| section_class.new self, find_first(*merge_args(find_args, runtime_args)), &runtime_block end end end |
#sections(section_collection_name, *args, &block) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/site_prism/element_container.rb', line 76 def sections(section_collection_name, *args, &block) section_class, find_args = (args, &block) build(section_collection_name, *find_args) do define_method(section_collection_name) do |*runtime_args, &element_block| raise_if_block(self, section_collection_name.to_s, !element_block.nil?) find_all(*merge_args(find_args, runtime_args)).map do |element| section_class.new(self, element) end end end end |