Module: RubySync::Connectors::ActiveRecordEventHandler

Defined in:
lib/ruby_sync/connectors/active_record_event_handler.rb

Instance Method Summary collapse

Instance Method Details

#delete_from_mirror(path) ⇒ Object



26
# File 'lib/ruby_sync/connectors/active_record_event_handler.rb', line 26

def delete_from_mirror(path); end

#each_changeObject

Process each RubySyncEvent and then delete it from the db.



29
30
31
32
33
34
35
# File 'lib/ruby_sync/connectors/active_record_event_handler.rb', line 29

def each_change
  ::RubySyncEvent.find(:all).each do |rse|
    event = RubySync::Event.new(rse.event_type, self, rse.trackable_id, nil, to_payload(rse))
    yield event
    ::RubySyncEvent.delete rse
  end
end

#to_payload(ar_event) ⇒ Object

Create a hash suitable to use as rubysync event payload



38
39
40
41
42
# File 'lib/ruby_sync/connectors/active_record_event_handler.rb', line 38

def to_payload ar_event
  ar_event.operations.map do |op|
    RubySync::Operation.new(op.operation.to_sym, op.field_name, op.values.map {|v| v.value})
  end
end

#update_mirror(path) ⇒ Object

Disable mirror updates for incoming events



25
# File 'lib/ruby_sync/connectors/active_record_event_handler.rb', line 25

def update_mirror(path); end