Created
January 26, 2012 22:55
-
-
Save hexgnu/1685651 to your computer and use it in GitHub Desktop.
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
#FIXME REFACTOR break this out, like, allot | |
def persist_posts(posts) | |
persisted = [] | |
NetworkPost.transaction do | |
persisted = posts.collect do |post| | |
klass = eval(self.type.to_s.gsub('Endpoint', '') + 'Post') | |
p = klass.handle_response(post) | |
next if p.nil? | |
p.network_endpoints << self unless p.network_endpoints.exists?(:id => self.id) | |
p.save | |
p | |
end | |
end | |
persisted | |
#so we don't barf on network returning something other then posts | |
rescue Exception => e | |
logger.error "Error persisting network posts: #{e}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment