Class: PageMagic::Element::Query
- Defined in:
- lib/page_magic/element/query.rb,
lib/page_magic/element/query/single_result.rb,
lib/page_magic/element/query/multiple_results.rb,
lib/page_magic/element/query/prefetched_result.rb
Overview
class Query - executes query on capybara driver
Direct Known Subclasses
Defined Under Namespace
Classes: MultipleResults, PrefetchedResult, SingleResult
Constant Summary collapse
- DEFAULT_DECORATOR =
proc { |arg| arg }.freeze
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#selector_args ⇒ Object
readonly
Returns the value of attribute selector_args.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#execute(capybara_element, &block) ⇒ Array<Capybara::Node::Element>, NullElement
TODO: - test for decoration? Run query against the scope of the given element The supplied block will be used to decorate the results.
-
#initialize(*selector_args, options: {}) ⇒ Query
constructor
A new instance of Query.
Constructor Details
#initialize(*selector_args, options: {}) ⇒ Query
Returns a new instance of Query.
14 15 16 17 |
# File 'lib/page_magic/element/query.rb', line 14 def initialize(*selector_args, options: {}) @selector_args = selector_args @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/page_magic/element/query.rb', line 10 def @options end |
#selector_args ⇒ Object (readonly)
Returns the value of attribute selector_args.
10 11 12 |
# File 'lib/page_magic/element/query.rb', line 10 def selector_args @selector_args end |
Instance Method Details
#==(other) ⇒ Object
31 32 33 34 |
# File 'lib/page_magic/element/query.rb', line 31 def ==(other) other.respond_to?(:selector_args) && selector_args == other.selector_args && other.respond_to?(:options) && == other. end |
#execute(capybara_element, &block) ⇒ Array<Capybara::Node::Element>, NullElement
TODO: - test for decoration? Run query against the scope of the given element The supplied block will be used to decorate the results
25 26 27 28 29 |
# File 'lib/page_magic/element/query.rb', line 25 def execute(, &block) find(, &(block || DEFAULT_DECORATOR)) rescue Capybara::ElementNotFound => e NotFound.new(e) end |