Sha256: abb946b8bdab630d6192bfce76bae98317792ac85eda495f514027f879a350c2

Contents?: true

Size: 760 Bytes

Versions: 2

Compression:

Stored size: 760 Bytes

Contents

module PageEz
  module MethodGenerators
    class HasManyDynamicSelector
      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

        HasManyStaticSelector.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_many_dynamic_selector.rb
page_ez-0.1.0 lib/page_ez/method_generators/has_many_dynamic_selector.rb