Class: Synced::Strategies::SyncedPerScopeTimestampStrategy
- Inherits:
-
Object
- Object
- Synced::Strategies::SyncedPerScopeTimestampStrategy
- Defined in:
- lib/synced/strategies/synced_per_scope_timestamp_strategy.rb
Overview
This is a strategy for UpdatedSince defining how to store and update synced timestamps. It uses a separate timestamps table to track when different models were synced in specific scopes.
Instance Method Summary collapse
-
#initialize(scope: nil, model_class:, **_options) ⇒ SyncedPerScopeTimestampStrategy
constructor
A new instance of SyncedPerScopeTimestampStrategy.
- #last_synced_at ⇒ Object
- #reset ⇒ Object
- #update(timestamp) ⇒ Object
Constructor Details
#initialize(scope: nil, model_class:, **_options) ⇒ SyncedPerScopeTimestampStrategy
Returns a new instance of SyncedPerScopeTimestampStrategy.
11 12 13 14 |
# File 'lib/synced/strategies/synced_per_scope_timestamp_strategy.rb', line 11 def initialize(scope: nil, model_class:, **) @scope = scope @model_class = model_class end |
Instance Method Details
#last_synced_at ⇒ Object
16 17 18 |
# File 'lib/synced/strategies/synced_per_scope_timestamp_strategy.rb', line 16 def last_synced_at .last_synced_at end |
#reset ⇒ Object
24 25 26 |
# File 'lib/synced/strategies/synced_per_scope_timestamp_strategy.rb', line 24 def reset .delete_all end |
#update(timestamp) ⇒ Object
20 21 22 |
# File 'lib/synced/strategies/synced_per_scope_timestamp_strategy.rb', line 20 def update() .create!(synced_at: ) end |