Class: PageEz::MethodGenerators::HasManyOrderedSelector

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

Defined Under Namespace

Classes: IndexedProcessor

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of HasManyOrderedSelector.



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

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

Instance Attribute Details

#selectorObject (readonly)

Returns the value of attribute selector.



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

def selector
  @selector
end

Instance Method Details

#run(target) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/page_ez/method_generators/has_many_ordered_selector.rb', line 13

def run(target)
  singularized_name = Pluralization.new(@name).singularize

  constructor = @core_selector.run(target)

  DefineHasOneResultMethods.new(
    "#{singularized_name}_at",
    evaluator_class: @evaluator_class,
    constructor: constructor,
    processor: IndexedProcessor
  ).run(target)

  DefineHasOnePredicateMethods.new(
    "#{singularized_name}_at",
    evaluator_class: @evaluator_class,
    processor: IndexedProcessor
  ).run(target)
end

#selector_typeObject



32
33
34
# File 'lib/page_ez/method_generators/has_many_ordered_selector.rb', line 32

def selector_type
  @core_selector.selector_type
end