Sha256: b73ef04a8279865f485e2033feb1827e34829e8927099eaeed870f5e38eef51e

Contents?: true

Size: 758 Bytes

Versions: 2

Compression:

Stored size: 758 Bytes

Contents

module PageEz
  module MethodGenerators
    class HasOneDynamicSelector
      attr_reader :selector

      def initialize(name, options, &block)
        @run = false
        @name = name
        @options = options
        @block = block
      end

      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

      def selector_type
        :dynamic
      end

      private

      def run?
        @run
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
page_ez-0.2.0 lib/page_ez/method_generators/has_one_dynamic_selector.rb
page_ez-0.1.0 lib/page_ez/method_generators/has_one_dynamic_selector.rb