Created
August 12, 2014 07:19
-
-
Save andrijaperovic/325faede94069777905c to your computer and use it in GitHub Desktop.
em example
This file contains 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
activity = self | |
EventMachine.run do | |
operation = proc { | |
if activity.new_contents.any? | |
sc = nil | |
while sc.nil? | |
sc = SiteContent.find(activity[:scontent_ids].first) rescue nil | |
sleep(0.1) | |
end | |
sc | |
else | |
SiteContent.find(activity[:scontent_ids].first) rescue nil | |
end | |
} | |
callback = proc { |sc| | |
puts sc.try(:as_json_cairo, {:fields => [:all]}) rescue nil | |
EventMachine.stop | |
} | |
EventMachine.defer(operation, callback) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment