Module: Nsync::ActiveRecord::Consumer::ClassMethods

Defined in:
lib/nsync/active_record/consumer/methods.rb

Instance Method Summary collapse

Instance Method Details

#nsync_add_data(consumer, event_type, filename, data) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/nsync/active_record/consumer/methods.rb', line 9

def nsync_add_data(consumer, event_type, filename, data)
  data = data.dup
  if nsync_opts[:id_key].to_s != "id"
    data[nsync_opts[:id_key].to_s] = data.delete("id")
    create(data)
  else
    id = data.delete("id")
    obj = new(data)
    obj.id = id
    obj.save
  end
end

#nsync_find(ids) ⇒ Object



5
6
7
# File 'lib/nsync/active_record/consumer/methods.rb', line 5

def nsync_find(ids)
  all(:conditions => {nsync_opts[:id_key] => ids})
end