Sha256: c14995b1e75fb92cf05df53fbfdcbcb883c88589bc733f84dd15a89e8f13a9e5

Contents?: true

Size: 958 Bytes

Versions: 26

Compression:

Stored size: 958 Bytes

Contents

module Hanami
  module Validations
    # Inline predicate
    #
    # @since 0.6.0
    # @api private
    class InlinePredicate
      # @since 0.6.0
      # @api private
      attr_reader :name

      # @since 0.6.0
      # @api private
      attr_reader :message

      # Return a new instance.
      #
      # @param name [Symbol] inline predicate name
      # @param message [String] optional failure message
      # @param blk [Proc] predicate implementation
      #
      # @return [Hanami::Validations::InlinePredicate] a new instance
      #
      # @since 0.6.0
      # @api private
      def initialize(name, message, &blk)
        @name    = name
        @message = message
        @blk     = blk
      end

      # @since 0.6.0
      # @api private
      def to_proc
        @blk
      end

      # @since 0.6.0
      # @api private
      def ==(other)
        self.class == other.class &&
          name == other.name
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
hanami-validations-1.3.6 lib/hanami/validations/inline_predicate.rb
hanami-validations-1.3.5 lib/hanami/validations/inline_predicate.rb
hanami-validations-1.3.4 lib/hanami/validations/inline_predicate.rb
hanami-validations-1.3.3 lib/hanami/validations/inline_predicate.rb
hanami-validations-1.3.2 lib/hanami/validations/inline_predicate.rb
hanami-validations-1.3.1 lib/hanami/validations/inline_predicate.rb
hanami-validations-1.3.0 lib/hanami/validations/inline_predicate.rb
hanami-validations-1.3.0.beta1 lib/hanami/validations/inline_predicate.rb
hanami-validations-1.2.2 lib/hanami/validations/inline_predicate.rb
hanami-validations-1.2.0 lib/hanami/validations/inline_predicate.rb
hanami-validations-1.2.0.rc2 lib/hanami/validations/inline_predicate.rb
hanami-validations-1.2.0.rc1 lib/hanami/validations/inline_predicate.rb
hanami-validations-1.2.0.beta2 lib/hanami/validations/inline_predicate.rb
hanami-validations-1.2.0.beta1 lib/hanami/validations/inline_predicate.rb
hanami-validations-1.1.0 lib/hanami/validations/inline_predicate.rb
hanami-validations-1.1.0.rc1 lib/hanami/validations/inline_predicate.rb
hanami-validations-1.1.0.beta3 lib/hanami/validations/inline_predicate.rb
hanami-validations-1.1.0.beta2 lib/hanami/validations/inline_predicate.rb
hanami-validations-1.1.0.beta1 lib/hanami/validations/inline_predicate.rb
hanami-validations-1.0.0 lib/hanami/validations/inline_predicate.rb