Skip to content

Instantly share code, notes, and snippets.

@hexgnu
Created January 26, 2012 22:55
Show Gist options
  • Save hexgnu/1685651 to your computer and use it in GitHub Desktop.
Save hexgnu/1685651 to your computer and use it in GitHub Desktop.
#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