Sha256: d94ceb37ad8debbf31aaebc732fa51fe08419753922f30938752c541894c772a

Contents?: true

Size: 990 Bytes

Versions: 8

Compression:

Stored size: 990 Bytes

Contents

class RubySyncObserver < ActiveRecord::Observer

  observe Person

  def after_create record
    event = RubySyncEvent.create  :timestamp=> Time.now,
                          :event_type=>'add',
                          :trackable_id=>record.id,
                          :trackable_type=>record.class.name,
                          :operations => RubySyncOperation.create_for(record, 'add')
  end
  
  def before_update record
    RubySyncEvent.create  :timestamp=> Time.now,
                          :event_type=>'modify',
                          :trackable_id=>record.id,
                          :trackable_type=>record.class.name,
                          :operations => RubySyncOperation.create_for(record, 'replace')
  end
  
  def after_destroy record
    RubySyncEvent.create  :timestamp=> Time.now,
                          :event_type=>'delete',
                          :trackable_id=>record.id,
                          :trackable_type=>record.class.name
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rubysync-0.0.1 examples/ar_webapp/app/models/ruby_sync_observer.rb
rubysync-0.1.1 examples/ar_webapp/app/models/ruby_sync_observer.rb
rubysync-0.0.3 examples/ar_webapp/app/models/ruby_sync_observer.rb
rubysync-0.2.1 examples/ar_webapp/app/models/ruby_sync_observer.rb
rubysync-0.0.2 examples/ar_webapp/app/models/ruby_sync_observer.rb
rubysync-0.0.4 examples/ar_webapp/app/models/ruby_sync_observer.rb
rubysync-0.1.0 examples/ar_webapp/app/models/ruby_sync_observer.rb
rubysync-0.0.5 examples/ar_webapp/app/models/ruby_sync_observer.rb