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.0.0.rc1 lib/hanami/validations/inline_predicate.rb
hanami-validations-1.0.0.beta2 lib/hanami/validations/inline_predicate.rb
hanami-validations-1.0.0.beta1 lib/hanami/validations/inline_predicate.rb
hanami-validations-0.7.1 lib/hanami/validations/inline_predicate.rb
hanami-validations-0.7.0 lib/hanami/validations/inline_predicate.rb
hanami-validations-0.6.0 lib/hanami/validations/inline_predicate.rb