lib/taza/page.rb in scudco-taza-0.8.5 vs lib/taza/page.rb in scudco-taza-0.8.6
- old
+ new
@@ -33,10 +33,12 @@
# homepage.foo.click
def self.element(name,&block)
if !@module.nil?
self.elements[@module] = Hash.new if self.elements[@module].nil?
self.elements[@module] = self.elements[@module].merge({ name => block })
+ elsif !self.elements[name].nil?
+ raise ElementError,"Duplicate definations for Element - #{name} on Page - #{self.to_s}"
else
self.elements[name] = block
end
end
@@ -72,21 +74,28 @@
def self.page_module(name,&block)
@module = name
yield(block)
@module = nil
end
+
+ def self.page_module_filter(method_name, page_module_name, *elements)
+ elements = [page_module_name] if elements.empty?
+ elements.each do |element|
+ self.filters[element] = self.filters[element] << method_name
+ end
+ end
def initialize(page_module = nil)
add_element_methods(page_module)
@active_filters = []
end
def add_element_methods(page_module = nil) # :nodoc:
self.class.elements.each do |element_name,element_block|
if (element_block.is_a?(Hash) && !page_module.nil? && page_module==element_name)
element_block.each do |key,value|
- filters = self.class.filters[element_name] + self.class.filters[:all]
+ filters = self.class.filters[element_name] + self.class.filters[:all] + self.class.filters[key]
add_element_method(:filters => filters, :element_name => key, :element_block => value)
end
else
filters = self.class.filters[element_name] + self.class.filters[:all]
add_element_method(:filters => filters, :element_name => element_name, :element_block => element_block)
@@ -113,6 +122,7 @@
end
end
end
class FilterError < StandardError; end
+ class ElementError < StandardError; end
end