Sha256: 39683d8d140a86085cd3f7db381e4fe768bae938f0e3479e944e24e57b79c333
Contents?: true
Size: 603 Bytes
Versions: 1
Compression:
Stored size: 603 Bytes
Contents
# assumes that @checks is defined as an array of no-arg lambdas, each # lambda raising an error (with useful msg) when check fails module Validatable attr_reader :errors def validate @errors = [] @check_methods.each do |check_method| begin send(check_method) rescue StandardError => e @errors.push e end end if respond_to?(:validatables) validatables.each do |v| @errors += v.validate end end return @errors end def valid? self.validate @errors.empty? end def invalid? !self.valid? end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
music-transcription-0.7.2 | lib/music-transcription/validatable.rb |