Class: PageEz::MethodGenerators::HasManyStaticSelector
- Inherits:
-
Object
- Object
- PageEz::MethodGenerators::HasManyStaticSelector
- Defined in:
- lib/page_ez/method_generators/has_many_static_selector.rb
Instance Attribute Summary collapse
-
#selector ⇒ Object
readonly
Returns the value of attribute selector.
Instance Method Summary collapse
-
#initialize(name, selector, dynamic_options, options, &block) ⇒ HasManyStaticSelector
constructor
A new instance of HasManyStaticSelector.
- #run(target) ⇒ Object
- #selector_type ⇒ Object
Constructor Details
#initialize(name, selector, dynamic_options, options, &block) ⇒ HasManyStaticSelector
Returns a new instance of HasManyStaticSelector.
6 7 8 9 10 11 |
# File 'lib/page_ez/method_generators/has_many_static_selector.rb', line 6 def initialize(name, selector, , , &block) @name = name @selector = selector @block = block @evaluator_class = SelectorEvaluator.build(name, dynamic_options: , options: , selector: selector) end |
Instance Attribute Details
#selector ⇒ Object (readonly)
Returns the value of attribute selector.
4 5 6 |
# File 'lib/page_ez/method_generators/has_many_static_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 31 32 33 34 |
# File 'lib/page_ez/method_generators/has_many_static_selector.rb', line 13 def run(target) target.constructor_from_block(&@block).tap do |constructor| DefineHasManyResultMethods.new( @name, evaluator_class: @evaluator_class, constructor: constructor ).run(target) singularized_name = Pluralization.new(@name).singularize DefineHasOneResultMethods.new( "#{singularized_name}_matching", evaluator_class: @evaluator_class, constructor: constructor ).run(target) DefineHasOnePredicateMethods.new( "#{singularized_name}_matching", evaluator_class: @evaluator_class ).run(target) end end |
#selector_type ⇒ Object
36 37 38 |
# File 'lib/page_ez/method_generators/has_many_static_selector.rb', line 36 def selector_type :static end |