Method: AX::Element#method_missing
- Defined in:
- lib/ax/element.rb
#method_missing(method, *args, &block) ⇒ Object
We use #method_missing to dynamically handle requests to lookup attributes or search for elements in the view hierarchy. An attribute lookup is always tried first, followed by a parameterized attribute lookup, and then finally a search.
Failing all lookups, this method calls super, which will probably
raise an exception; however, most elements have children and so it
is more likely that you will get an Accessibility::SearchFailure
in cases where you sholud get a NoMethodError.
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
# File 'lib/ax/element.rb', line 353 def method_missing method, *args, &block return set(method.to_s.chomp(EQUALS), args.first) if method[-1] == EQUALS key = TRANSLATOR.cocoaify method if @ref.attributes.include? key return attribute(method) elsif @ref.parameterized_attributes.include? key return parameterized_attribute(method, args.first) elsif @ref.attributes.include? KAXChildrenAttribute if (result = search(method, *args, &block)).blank? raise Accessibility::SearchFailure.new(self, method, args.first, &block) else return result end else super end end |