Active Resource validation is reported to and from this object, which is used by Base#save to determine whether the object in a valid state to be saved. See usage example in Validations.

Methods
F
Instance Public methods
from_array(messages, save_cache = false)

Grabs errors from an array of messages (like ActiveRecord::Validations). The second parameter directs the errors cache to be cleared (default) or not (by passing true).

    # File activeresource/lib/active_resource/validations.rb, line 14
14:     def from_array(messages, save_cache = false)
15:       clear unless save_cache
16:       humanized_attributes = Hash[@base.attributes.keys.map { |attr_name| [attr_name.humanize, attr_name] }]
17:       messages.each do |message|
18:         attr_message = humanized_attributes.keys.detect do |attr_name|
19:           if message[0, attr_name.size + 1] == "#{attr_name} "
20:             add humanized_attributes[attr_name], message[(attr_name.size + 1)..-1]
21:           end
22:         end
23: 
24:         self[:base] << message if attr_message.nil?
25:       end
26:     end
from_json(json, save_cache = false)

Grabs errors from a json response.

    # File activeresource/lib/active_resource/validations.rb, line 29
29:     def from_json(json, save_cache = false)
30:       array = Array.wrap(ActiveSupport::JSON.decode(json)['errors']) rescue []
31:       from_array array, save_cache
32:     end
from_xml(xml, save_cache = false)

Grabs errors from an XML response.

    # File activeresource/lib/active_resource/validations.rb, line 35
35:     def from_xml(xml, save_cache = false)
36:       array = Array.wrap(Hash.from_xml(xml)['errors']['error']) rescue []
37:       from_array array, save_cache
38:     end