class Restforce::DB::Tracker
Restforce::DB::Tracker
encapsulates a minimal API to track and configure synchronization runtimes. It allows Restforce::DB
to persist a “last successful sync” timestamp.
Attributes
last_run[R]
Public Class Methods
new(file_path)
click to toggle source
Public: Initialize a Restforce::DB::Tracker
. Sets a last_run
timestamp on Restforce::DB
if the supplied tracking file already contains a stamp.
file_path - The Path to the tracking file.
# File lib/restforce/db/tracker.rb, line 16 def initialize(file_path) @file_path = file_path timestamp = File.open(@file_path, "a+") { |file| file.read } return if timestamp.empty? @last_run = Time.parse(timestamp) Restforce::DB.last_run = @last_run end
Public Instance Methods
track(time)
click to toggle source
Public: Persist the passed time in the tracker file.
time - A Time object.
Returns nothing.
# File lib/restforce/db/tracker.rb, line 31 def track(time) @last_run = time File.open(@file_path, "w") { |file| file.write(time.utc.iso8601) } end