Sha256: 0fd0a06705073bea1743ccd896e897b00218e8cf9a8c25af1262a08279f0d1b5

Contents?: true

Size: 440 Bytes

Versions: 1

Compression:

Stored size: 440 Bytes

Contents

module Cavalry
  class Validator
    class EachValidator
      attr_reader :source_class

      def initialize(klass, &block)
        @source_class = klass
        @source_class.class_eval(&block)
      end

      def validate
        source_class.all.flat_map {|record| validate_record(record) }.compact
      end

      private

      def validate_record(record)
        return if record.valid?
        record
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cavalry-0.1.0 lib/cavalry/validator/each_validator.rb