class Reorm::PropertyErrors

Public Class Methods

new() click to toggle source
# File lib/reorm/property_errors.rb, line 7
def initialize
        @errors = {}
end

Public Instance Methods

add(property, message) click to toggle source
# File lib/reorm/property_errors.rb, line 23
def add(property, message)
        if ![nil, ""].include?(message)
                @errors[property.to_sym] = [] if !@errors.include?(property.to_sym)
                @errors[property.to_sym] << message
        end
        self
end
clear?() click to toggle source
# File lib/reorm/property_errors.rb, line 11
def clear?
        @errors.empty?
end
each() { |property, messages| ... } click to toggle source
# File lib/reorm/property_errors.rb, line 39
def each
        @errors.each {|property, messages| yield(property, messages)}
end
include?(property) click to toggle source
# File lib/reorm/property_errors.rb, line 19
def include?(property)
        @errors.include?(property.to_sym)
end
messages(property) click to toggle source
# File lib/reorm/property_errors.rb, line 35
def messages(property)
        [].concat(@errors.fetch(property.to_sym, []))
end
properties() click to toggle source
# File lib/reorm/property_errors.rb, line 31
def properties
                    @errors.keys
            end
reset() click to toggle source
# File lib/reorm/property_errors.rb, line 15
def reset
        @errors = {}
end
to_s() click to toggle source
# File lib/reorm/property_errors.rb, line 43
def to_s
        text = StringIO.new
        @errors.each do |property, messages|
                messages.each do |message|
                        text << "#{text.size > 0 ? "\n" : ""}#{property} #{message}"
                end
        end
        text.string
end