Class: PageEz::MethodGenerators::HasOneStaticSelector

Inherits:
Object
  • Object
show all
Defined in:
lib/page_ez/method_generators/has_one_static_selector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, selector, dynamic_options, options, &block) ⇒ HasOneStaticSelector

Returns a new instance of HasOneStaticSelector.



6
7
8
9
10
11
# File 'lib/page_ez/method_generators/has_one_static_selector.rb', line 6

def initialize(name, selector, dynamic_options, options, &block)
  @name = name
  @selector = selector
  @evaluator_class = SelectorEvaluator.build(name, dynamic_options: dynamic_options, options: options, selector: selector)
  @block = block
end

Instance Attribute Details

#selectorObject (readonly)

Returns the value of attribute selector.



4
5
6
# File 'lib/page_ez/method_generators/has_one_static_selector.rb', line 4

def selector
  @selector
end

Instance Method Details

#run(target) ⇒ Object



13
14
15
16
17
18
# File 'lib/page_ez/method_generators/has_one_static_selector.rb', line 13

def run(target)
  constructor = target.constructor_from_block(&@block)

  DefineHasOneResultMethods.new(@name, evaluator_class: @evaluator_class, constructor: constructor).run(target)
  DefineHasOnePredicateMethods.new(@name, evaluator_class: @evaluator_class).run(target)
end

#selector_typeObject



20
21
22
# File 'lib/page_ez/method_generators/has_one_static_selector.rb', line 20

def selector_type
  :static
end