Sha256: dcb0f1409b7cba3da51048aef521dd52d65010466645c03636f1d8e6e3813ae1

Contents?: true

Size: 572 Bytes

Versions: 20

Compression:

Stored size: 572 Bytes

Contents

module Shogun
  module Verifier
    class Match
      def initialize(data:, name:, comparison:)
        @data = data
        @name = name
        @comparison = comparison
      end

      def valid?
        if @comparison.is_a?(Regexp)
          @data =~ @comparison
        else
          @data == @comparison || @comparison == @data
        end
      end

      def id
        "#{@name}_does_not_match"
      end

      def context
        if @comparison.is_a?(Regexp)
          {
            "pattern" => @comparison
          }
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
shogun-6.4.2 lib/shogun/verifier/match.rb
shogun-6.4.1 lib/shogun/verifier/match.rb
shogun-6.4.0 lib/shogun/verifier/match.rb
shogun-6.3.0 lib/shogun/verifier/match.rb
shogun-6.2.3 lib/shogun/verifier/match.rb
shogun-6.2.2 lib/shogun/verifier/match.rb
shogun-6.2.1 lib/shogun/verifier/match.rb
shogun-6.2.0 lib/shogun/verifier/match.rb
shogun-6.1.0 lib/shogun/verifier/match.rb
shogun-6.0.0 lib/shogun/verifier/match.rb
shogun-4.0.1 lib/shogun/verifier/match.rb
shogun-4.0.0 lib/shogun/verifier/match.rb
shogun-3.4.0 lib/shogun/verifier/match.rb
shogun-3.2.0 lib/shogun/verifier/match.rb
shogun-3.1.0 lib/shogun/verifier/match.rb
shogun-3.0.0 lib/shogun/verifier/match.rb
shogun-2.1.1 lib/shogun/verifier/match.rb
shogun-2.1.0 lib/shogun/verifier/match.rb
shogun-2.0.0 lib/shogun/verifier/match.rb
shogun-1.0.0 lib/shogun/verifier/match.rb