Class: PageEz::MethodGenerators::HasOneDynamicSelector
- Inherits:
-
Object
- Object
- PageEz::MethodGenerators::HasOneDynamicSelector
- Defined in:
- lib/page_ez/method_generators/has_one_dynamic_selector.rb
Instance Attribute Summary collapse
-
#selector ⇒ Object
readonly
Returns the value of attribute selector.
Instance Method Summary collapse
-
#initialize(name, options, &block) ⇒ HasOneDynamicSelector
constructor
A new instance of HasOneDynamicSelector.
- #run(target) ⇒ Object
- #selector_type ⇒ Object
Constructor Details
#initialize(name, options, &block) ⇒ HasOneDynamicSelector
Returns a new instance of HasOneDynamicSelector.
6 7 8 9 10 11 |
# File 'lib/page_ez/method_generators/has_one_dynamic_selector.rb', line 6 def initialize(name, , &block) @run = false @name = name @options = @block = block end |
Instance Attribute Details
#selector ⇒ Object (readonly)
Returns the value of attribute selector.
4 5 6 |
# File 'lib/page_ez/method_generators/has_one_dynamic_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 |
# File 'lib/page_ez/method_generators/has_one_dynamic_selector.rb', line 13 def run(target) return if run? if target.method_defined?(@name) target.rename_method from: @name, to: :"_#{@name}" @run = true @selector = target.instance_method(:"_#{@name}") else @selector = @name.to_s end HasOneStaticSelector.new(@name, @selector, nil, @options, &@block).run(target) end |
#selector_type ⇒ Object
28 29 30 |
# File 'lib/page_ez/method_generators/has_one_dynamic_selector.rb', line 28 def selector_type :dynamic end |