def to_hash(full_messages = false)
      if full_messages
        messages = {}
        self.messages.each do |attribute, array|
          messages[attribute] = array.map { |message| full_message(attribute, message) }
        end
        messages
      else
        self.messages.dup
      end
    end
def to_hash(full_messages = false)
      if full_messages
        messages = {}
        self.messages.each do |attribute, array|
          messages[attribute] = array.map { |message| full_message(attribute, message) }
        end
        messages
      else
        self.messages.dup
      end
    end
Returns a Hash of attributes with their error messages. If +full_messages+
 is +true+, it will contain full messages (see +full_message+).

   person.to_hash       # => {:name=>["can not be nil"]}
   person.to_hash(true) # => {:name=>["name can not be nil"]}