lib/domkey/view/page_object.rb in domkey-0.3.1 vs lib/domkey/view/page_object.rb in domkey-0.4.0
- old
+ new
@@ -79,21 +79,21 @@
# @api private
# delegate to element when element responds to message
def method_missing(message, *args, &block)
- if respond_to_missing?(message, false)
+ if element.respond_to?(message)
element.__send__(message, *args, &block)
else
super
end
end
# @api private
# ruturn true when element.respond_to? message so we can delegate with confidence
def respond_to_missing?(message, include_private = false)
- element.respond_to?(message) ? true : false
+ element.respond_to?(message) || super
end
private
# wrap instantiator with strategy for setting and getting value for underlying object
@@ -114,19 +114,19 @@
# peek inside suitcase that is proc. XXX ouch, ugly
peeked_inside = package.call
rescue StandardError
return package #suitecase exploded, proc returned
end
- if peeked_inside.respond_to?(:each_pair) # hash
+ if peeked_inside.kind_of?(Hash)
return initialize_this peeked_inside
- elsif peeked_inside.respond_to?(:wd) # watir element
+ elsif peeked_inside.kind_of?(Watir::Container)
return lambda { peeked_inside }
- elsif peeked_inside.respond_to?(:package) #pageobject
+ elsif peeked_inside.kind_of?(PageObject)
return peeked_inside.package
else
fail Exception::Error, "package must be kind of hash, watirelement or pageobject but I got this: #{package}"
end
- elsif package.respond_to?(:package) #pageobject
+ elsif package.respond_to?(:package, true) #pageobject
return package.package
else
fail Exception::Error, "package must be kind of hash, watirelement or pageobject but I got this: #{package}"
end
end
\ No newline at end of file