Class: WatermelonDbSync::SyncPull
- Defined in:
- lib/watermelon_db_sync/sync_pull.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#last_pulled_version ⇒ Object
Returns the value of attribute last_pulled_version.
-
#models ⇒ Object
Returns the value of attribute models.
Instance Method Summary collapse
- #get_from_all ⇒ Object
-
#initialize(params) ⇒ SyncPull
constructor
A new instance of SyncPull.
- #pull ⇒ Object
Methods inherited from Sync
last_global_seqs, next_global_seqs
Constructor Details
#initialize(params) ⇒ SyncPull
Returns a new instance of SyncPull.
5 6 7 8 9 10 |
# File 'lib/watermelon_db_sync/sync_pull.rb', line 5 def initialize(params) @last_pulled_version = params[:last_pulled_version].to_i || 0 @push_id = params[:push_id] @models = WatermelonDbSync.configuration.sync_models @data = { last_global_seqs: 0, response: build_default_response } end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
3 4 5 |
# File 'lib/watermelon_db_sync/sync_pull.rb', line 3 def data @data end |
#last_pulled_version ⇒ Object
Returns the value of attribute last_pulled_version.
3 4 5 |
# File 'lib/watermelon_db_sync/sync_pull.rb', line 3 def last_pulled_version @last_pulled_version end |
#models ⇒ Object
Returns the value of attribute models.
3 4 5 |
# File 'lib/watermelon_db_sync/sync_pull.rb', line 3 def models @models end |
Instance Method Details
#get_from_all ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/watermelon_db_sync/sync_pull.rb', line 16 def get_from_all max_versions = @models.map do |model_name| model = model_name.constantize query(model) end @data[:last_global_seqs] = max_versions.flatten.compact.max || @last_pulled_version true rescue => e e. end |
#pull ⇒ Object
12 13 14 |
# File 'lib/watermelon_db_sync/sync_pull.rb', line 12 def pull get_from_all end |