lib/taza/page.rb in bret-watircraft-0.4.5 vs lib/taza/page.rb in bret-watircraft-0.5.0
- old
+ new
@@ -27,14 +27,18 @@
end
def filters # :nodoc:
@filters ||= Hash.new { [] }
end
-
+
def fields # :nodoc:
@fields ||= []
end
+
+ def tables # :nodoc:
+ @tables ||= []
+ end
def url string=nil
if string.nil?
@url
else
@@ -139,10 +143,11 @@
#
# Technical details: this method creates a
# subclass and then allows its class methods to define fields and
# elements on the table.
def table(name, &block)
+ tables << name
# create subclass for the table
sub_class = Class.new(WatirCraft::Table)
sub_class.class_eval &block
# add method to the page, it returns an instance of the table subclass
define_method(name) do
@@ -217,9 +222,14 @@
end
# Return the names of the fields defined for the page.
def fields
self.class.fields.map &:to_s
+ end
+
+ # Return the names of the tables defined for the page.
+ def tables
+ self.class.tables.map &:to_s
end
# Returns a hash with the names and values of the specified fields.
# If no fields are specifieds, all fields on the page are used.
def values field_names=fields