Sha256: c1a73901042bb0d3bf365e6fc1b9c81e80949ef345d962a4b44d209735371d85

Contents?: true

Size: 768 Bytes

Versions: 2

Compression:

Stored size: 768 Bytes

Contents

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

        HasManyOrderedSelector.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_ordered_dynamic_selector.rb
page_ez-0.1.0 lib/page_ez/method_generators/has_many_ordered_dynamic_selector.rb