Class: TrafficMansion::QueueProcessor
- Inherits:
-
Object
- Object
- TrafficMansion::QueueProcessor
- Includes:
- Sidekiq::Worker
- Defined in:
- lib/traffic_mansion/queue_processor.rb
Instance Method Summary collapse
Instance Method Details
#deserialize_id(value) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/traffic_mansion/queue_processor.rb', line 24 def deserialize_id value if value.is_a? Hash value["$oid"] || value #maybe it's a genuine hash argument else value #some other parameter end end |
#perform(*args) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/traffic_mansion/queue_processor.rb', line 17 def perform *args Mongoid.unit_of_work(disable: :all) do args.map!{|arg| deserialize_id(arg)} work(*args) end end |
#work(event_id) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/traffic_mansion/queue_processor.rb', line 8 def work(event_id) begin event = TrafficMansion::Queue.find_by_id(event_id) if event && !event.processed event.process end end end |