Sha256: e1b135dec9f929d3600aa3ea6cda71eddecf54a4edd7f9a8335ac7e789e62f61

Contents?: true

Size: 783 Bytes

Versions: 3

Compression:

Stored size: 783 Bytes

Contents

# -*- encoding: utf-8 -*-

module Vanguard

  # Abstract base class for resource rules
  class Rule
    include AbstractType, Adamantium::Flat

    # Return violations for resource
    #
    # @param [Resource] resource
    #
    # @return [Enumerable<Violations>]
    #
    def violations(resource)
      evaluate(resource).violations
    end

    # Return evaluator for resource
    #
    # @param [Object] resource
    #   the target object to be validated
    #
    # @return [Evaluator]
    #
    # @api private
    #
    def evaluate(resource)
      evaluator.new(self, resource)
    end

    # Return evaluator
    #
    # @return [Class:Evaluator]
    #
    # @api private
    #
    def evaluator
      self.class::Evaluator
    end

  end # class Rule
end # module Vanguard

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vanguard-0.0.5 lib/vanguard/rule.rb
vanguard-0.0.4 lib/vanguard/rule.rb
vanguard-0.0.3 lib/vanguard/rule.rb