Class: Syncinator

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document
Defined in:
lib/trogdir/syncinator.rb

Constant Summary collapse

FIXNUM_MAX =
(2**(0.size * 8 -2) -1)

Instance Method Summary collapse

Instance Method Details

#error!(sync_log, message) ⇒ Object



44
45
46
47
# File 'lib/trogdir/syncinator.rb', line 44

def error!(sync_log, message)
  sync_log.update_attributes errored_at: Time.now, message: message
  sync_log
end

#finish!(sync_log, action, message = nil) ⇒ Object



49
50
51
52
# File 'lib/trogdir/syncinator.rb', line 49

def finish!(sync_log, action, message = nil)
  sync_log.update_attributes succeeded_at: Time.now, action: action, message: message
  sync_log
end

#start!(changeset) ⇒ Object



38
39
40
41
42
# File 'lib/trogdir/syncinator.rb', line 38

def start!(changeset)
  return false unless change_sync = change_sync_for(changeset)

  change_sync.sync_logs.create! started_at: Time.now
end

#startable_changesetsObject



32
33
34
35
36
# File 'lib/trogdir/syncinator.rb', line 32

def startable_changesets
  Changeset.where(
    :change_syncs.elem_match => {syncinator_id: id, :run_after.lt => Time.now }
  ).order_by(created_at: :asc)
end

#to_sObject



22
23
24
# File 'lib/trogdir/syncinator.rb', line 22

def to_s
  name
end

#unfinished_changesetsObject



26
27
28
29
30
# File 'lib/trogdir/syncinator.rb', line 26

def unfinished_changesets
  Changeset.where(
    :change_syncs.elem_match => {syncinator_id: id, :run_after.ne => nil}
  ).order_by(created_at: :asc)
end