Sha256: 3a676f80ab1a5631b063de314265e9a8e81041cf088daed6356ed514238d0b4c

Contents?: true

Size: 879 Bytes

Versions: 5

Compression:

Stored size: 879 Bytes

Contents

module Qujo
  module Database
    module Mongoid
      extend ActiveSupport::Concern

      included do
        raise Qujo::Exceptions::DatabaseUndefined, "Mongoid is undefined" unless defined?(Mongoid)
        include ::Mongoid::Document
        include ::Mongoid::Timestamps
        include ::Mongoid::Symbolize

        field :data, type: Hash
        symbolize :status, in: [:new, :working, :waiting, :complete, :error, :retry, :cancelled], default: "new"
        field :message, type: String
        field :log, type: Array, default: []
        field :trace, type: Array, default: []
        field :accepted_at, type: DateTime

        default_scope where(accepted_at: nil)
        scope :active, -> { where(:status.in => [:new, :working, :waiting, :retry, :error], accepted_at: nil) }
        scope :errors, -> { where(:status.in => [:error]) }
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
qujo-0.1.4 lib/qujo/database/mongoid.rb
qujo-0.1.3 lib/qujo/database/mongoid.rb
qujo-0.1.2 lib/qujo/database/mongoid.rb
qujo-0.1.1 lib/qujo/database/mongoid.rb
qujo-0.1.0 lib/qujo/database/mongoid.rb