Class: PageMagic::ElementContext
- Defined in:
- lib/page_magic/element_context.rb
Overview
class ElementContext - resolves which element definition to use when accessing the browser.
Instance Attribute Summary collapse
-
#page_element ⇒ Object
readonly
Returns the value of attribute page_element.
Instance Method Summary collapse
-
#initialize(page_element) ⇒ ElementContext
constructor
A new instance of ElementContext.
-
#method_missing(method, *args, &block) ⇒ Object, ...
acts as proxy to element definitions defined on @page_element.
- #respond_to_missing?(*args) ⇒ Boolean
Constructor Details
#initialize(page_element) ⇒ ElementContext
Returns a new instance of ElementContext.
8 9 10 |
# File 'lib/page_magic/element_context.rb', line 8 def initialize(page_element) @page_element = page_element end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object, ...
acts as proxy to element definitions defined on @page_element
16 17 18 19 20 21 22 23 24 |
# File 'lib/page_magic/element_context.rb', line 16 def method_missing(method, *args, &block) return page_element.send(method, *args, &block) if page_element.methods.include?(method) builder = page_element.element_by_name(method, *args) super unless builder builder.build(page_element.browser_element) end |
Instance Attribute Details
#page_element ⇒ Object (readonly)
Returns the value of attribute page_element.
6 7 8 |
# File 'lib/page_magic/element_context.rb', line 6 def page_element @page_element end |
Instance Method Details
#respond_to_missing?(*args) ⇒ Boolean
26 27 28 |
# File 'lib/page_magic/element_context.rb', line 26 def respond_to_missing?(*args) page_element.respond_to?(*args) || super end |