Sha256: aa2e67b6c930f94eeb149aee986df164fde134a82ffc9f96aedf272a77ce0fea

Contents?: true

Size: 672 Bytes

Versions: 6

Compression:

Stored size: 672 Bytes

Contents

module Seam
  module Persistence
    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 } } )
        .map { |x| Seam::Effort.parse x }
    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
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
seam-0.0.6 lib/seam/persistence.rb
seam-0.0.5 lib/seam/persistence.rb
seam-0.0.4 lib/seam/persistence.rb
seam-0.0.3 lib/seam/persistence.rb
seam-0.0.2 lib/seam/persistence.rb
seam-0.0.1 lib/seam/persistence.rb