Class: Restforce::DB::Tracker
- Inherits:
-
Object
- Object
- Restforce::DB::Tracker
- Defined in:
- lib/restforce/db/tracker.rb
Overview
Restforce::DB::Tracker encapsulates a minimal API to track and configure synchronization runtimes. It allows Restforce::DB to persist a “last successful sync” timestamp.
Instance Attribute Summary collapse
-
#last_run ⇒ Object
readonly
Returns the value of attribute last_run.
Instance Method Summary collapse
-
#initialize(file_path) ⇒ Tracker
constructor
Public: Initialize a Restforce::DB::Tracker.
-
#track(time) ⇒ Object
Public: Persist the passed time in the tracker file.
Constructor Details
#initialize(file_path) ⇒ Tracker
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.
16 17 18 19 20 21 22 23 24 |
# File 'lib/restforce/db/tracker.rb', line 16 def initialize(file_path) @file_path = file_path = File.open(@file_path, "a+") { |file| file.read } return if .empty? @last_run = Time.parse() Restforce::DB.last_run = @last_run end |
Instance Attribute Details
#last_run ⇒ Object (readonly)
Returns the value of attribute last_run.
10 11 12 |
# File 'lib/restforce/db/tracker.rb', line 10 def last_run @last_run end |
Instance Method Details
#track(time) ⇒ Object
Public: Persist the passed time in the tracker file.
time - A Time object.
Returns nothing.
31 32 33 34 |
# 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 |