Sha256: 8b19accc25f48b6ba5f7d804ed1f85c01e1eefe418eebccca5158e7b28fee181

Contents?: true

Size: 747 Bytes

Versions: 2

Compression:

Stored size: 747 Bytes

Contents

# encoding: utf-8

module Attestor

  module Validations

    # Describe a validator that delegates validation to instance method or block
    #
    # The follower not only calls an instance method (block) as validator does,
    # but calls #validate method of the result.
    #
    # @example
    #   follower = Validator.new(:foo, only: :baz) { FooPolicy.new(foo) }
    #
    # @api private
    class Delegator < Validator

      # Validates an object by delegation
      #
      # @param [Object] object
      #
      # @raise [Attestor::InvalidError] if a policy isn't valid
      #
      # @return [undefined]
      def validate(_)
        super.validate
      end

    end # class Follower

  end # module Validations

end # module Attestor

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
attestor-1.0.0 lib/attestor/validations/delegator.rb
attestor-0.4.0 lib/attestor/validations/delegator.rb