Module: SyncableModels::ActiveRecord
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/syncable_models/active_record.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #clear_syncs(destination = nil) ⇒ Object
- #clear_syncs_on_update ⇒ Object
- #sync(destination) ⇒ Object
- #synced?(destination) ⇒ Boolean
- #to_import_hash ⇒ Object
Instance Method Details
#clear_syncs(destination = nil) ⇒ Object
29 30 31 32 |
# File 'lib/syncable_models/active_record.rb', line 29 def clear_syncs(destination = nil) syncs = destination ? self.syncs.by_destination(destination) : self.syncs syncs.destroy_all end |
#clear_syncs_on_update ⇒ Object
34 35 36 |
# File 'lib/syncable_models/active_record.rb', line 34 def clear_syncs_on_update self.clear_syncs end |
#sync(destination) ⇒ Object
25 26 27 |
# File 'lib/syncable_models/active_record.rb', line 25 def sync(destination) self.syncs.create(destination: destination) unless self.synced?(destination) end |
#synced?(destination) ⇒ Boolean
21 22 23 |
# File 'lib/syncable_models/active_record.rb', line 21 def synced?(destination) self.syncs.where(destination: destination).exists? end |
#to_import_hash ⇒ Object
38 39 40 |
# File 'lib/syncable_models/active_record.rb', line 38 def to_import_hash self.attributes end |