Class: PageEz::MethodGenerators::DefineHasOnePredicateMethods
- Inherits:
-
Object
- Object
- PageEz::MethodGenerators::DefineHasOnePredicateMethods
- Defined in:
- lib/page_ez/method_generators/define_has_one_predicate_methods.rb
Instance Method Summary collapse
-
#initialize(name, evaluator_class:, processor: IdentityProcessor) ⇒ DefineHasOnePredicateMethods
constructor
A new instance of DefineHasOnePredicateMethods.
- #run(target) ⇒ Object
Constructor Details
#initialize(name, evaluator_class:, processor: IdentityProcessor) ⇒ DefineHasOnePredicateMethods
Returns a new instance of DefineHasOnePredicateMethods.
4 5 6 7 8 |
# File 'lib/page_ez/method_generators/define_has_one_predicate_methods.rb', line 4 def initialize(name, evaluator_class:, processor: IdentityProcessor) @name = name @evaluator_class = evaluator_class @processor = processor end |
Instance Method Details
#run(target) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/page_ez/method_generators/define_has_one_predicate_methods.rb', line 10 def run(target) evaluator_class = @evaluator_class processor = @processor target.logged_define_method("has_#{@name}?") do |*args| evaluator = evaluator_class.run(processor.run_args(args), target: self) selector = processor.selector(evaluator.selector, args) PageEz.reraise_selector_error(selector) do has_css?( selector, **evaluator. ) end end target.logged_define_method("has_no_#{@name}?") do |*args| evaluator = evaluator_class.run(processor.run_args(args), target: self) selector = processor.selector(evaluator.selector, args) PageEz.reraise_selector_error(selector) do has_no_css?( selector, **evaluator. ) end end end |