Sha256: 6a7c7e14cc16e49e7b11f8b36eab162b00a9ecd0425a0ebb2f1314a6af4f9dfe

Contents?: true

Size: 662 Bytes

Versions: 4

Compression:

Stored size: 662 Bytes

Contents

module Cavalry
  class Client
    attr_reader :errors

    def initialize(config)
      @config = config
      @errors = []

      config.load_models
      config.load_validators
    end

    def run
      @errors = all_validators.flat_map do |klass|
        klass.execute_validation
      end
      @done = true
    end

    def done?
      @done
    end

    def dump
      errors.map(&:dump)
    end

    private

    def all_validators
      @all_validators ||= ObjectSpace.each_object(::Cavalry::Validator.singleton_class).map do |k|
        next if k.singleton_class?
        next if k == ::Cavalry::Validator
        k
      end.compact
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cavalry-0.2.2 lib/cavalry/client.rb
cavalry-0.2.1 lib/cavalry/client.rb
cavalry-0.2.0 lib/cavalry/client.rb
cavalry-0.1.0 lib/cavalry/client.rb