Sha256: 3713968ef8bf4b23b7f0cb30875013b171e18e77551bda6818ab5bd95f9a2cff

Contents?: true

Size: 825 Bytes

Versions: 5

Compression:

Stored size: 825 Bytes

Contents

# frozen_string_literal: true
require 'capybara/selector/filter'

module Capybara
  class Selector
    class ExpressionFilter < Filter
      undef_method :matches?

      def apply_filter(expr, value)
        return expr if skip?(value)

        if !valid_value?(value)
          msg = "Invalid value #{value.inspect} passed to expression filter #{@name} - "
          if default?
            warn msg + "defaulting to #{default}"
            value = default
          else
            warn msg + "skipping"
            return expr
          end
        end

        @block.call(expr, value)
      end
    end

    class IdentityExpressionFilter < ExpressionFilter
      def initialize
      end

      def default?
        false
      end

      def apply_filter(expr, _value)
        return expr
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
tdiary-5.0.5 vendor/bundle/gems/capybara-2.14.3/lib/capybara/selector/expression_filter.rb
capybara-2.14.4 lib/capybara/selector/expression_filter.rb
capybara-2.14.3 lib/capybara/selector/expression_filter.rb
capybara-2.14.2 lib/capybara/selector/expression_filter.rb
capybara-2.14.1 lib/capybara/selector/expression_filter.rb