18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/seam/mongodb.rb', line 18
def self.overwrite_the_persistence_layer
Seam::Persistence.class_eval do
def self.find_by_effort_id effort_id
document = Seam::Mongodb.collection.find( { id: effort_id } ).first
return nil unless document
Seam::Effort.parse document
end
def self.find_all_pending_executions_by_step step
Seam::Mongodb.collection
.find( { next_step: step, next_execute_at: { '$lte' => Time.now } } )
.select( { '_id' => 1 } )
.map do |x|
-> do
record = Seam::Mongodb.collection.find( { '_id' => x['_id'] } ).first
Seam::Effort.parse record
end.to_object
end
end
def self.save effort
Seam::Mongodb.collection
.find( { id: effort.id } )
.update("$set" => effort.to_hash)
end
def self.create effort
Seam::Mongodb.collection.insert(effort.to_hash)
end
def self.all
Seam::Mongodb.collection.find.to_a
end
def self.destroy
Seam::Mongodb.collection.drop
end
end
end
|