Created
March 11, 2010 21:40
-
-
Save teeparham/329698 to your computer and use it in GitHub Desktop.
deserialize an array of ActiveRecord objects from xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveRecord | |
class Base | |
# extends the patch here: http://www.xcombinator.com/2008/08/11/activerecord-from_xml-and-from_json-part-2/ | |
def self.array_from_xml(xml) | |
hash_array = Hash.from_xml(xml).values.first | |
hash_array.nil? ? [] : hash_array.collect {|attributes_hash| from_hash(attributes_hash)} | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment