Sha256: ccf0ead74bd6505d220fe0cec960fd967742f2a56f5410639e2b8d32fed3fbba

Contents?: true

Size: 446 Bytes

Versions: 5

Compression:

Stored size: 446 Bytes

Contents

module Judge

  class ValidatorCollection

    include Enumerable

    attr_reader :validators
    
    def initialize(object, method)
      amvs = object.class.validators_on(method)
      @validators = amvs.map { |amv| Judge::Validator.new(object, method, amv) }
    end

    def each(&block)
      validators.each do |v|
        block.call(v)
      end
    end

    def to_json
      validators.map { |v| v.to_hash }.to_json
    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
judge-2.0.4 lib/judge/validator_collection.rb
judge-2.0.3 lib/judge/validator_collection.rb
judge-2.0.2 lib/judge/validator_collection.rb
judge-2.0.1 lib/judge/validator_collection.rb
judge-2.0.0 lib/judge/validator_collection.rb