resty-generators 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,7 @@
|
|
6
6
|
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
|
7
7
|
# Mayor.create(:name => 'Daley', :city => cities.first)
|
8
8
|
<% if options[:remote_users] -%>
|
9
|
-
u = User.new(:name => "
|
9
|
+
u = User.new(:name => "System", :login => "system")
|
10
10
|
u.id = 0
|
11
11
|
u.save
|
12
12
|
<% end -%>
|
@@ -36,8 +36,14 @@ class Ixtlan::Core::Heartbeat
|
|
36
36
|
last_update = res.local.maximum(:updated_at) || 2000.years.ago
|
37
37
|
last_update = last_update.strftime('%Y-%m-%d %H:%M:%S.') + ("%06d" % last_update.usec)
|
38
38
|
res.remote.get(:last_changes, :updated_at => last_update).each do |remote|
|
39
|
-
|
40
|
-
u.
|
39
|
+
id = remote.delete('id')
|
40
|
+
u = res.local.find_by_id(id)
|
41
|
+
if u
|
42
|
+
u.update_attributes(remote)
|
43
|
+
else
|
44
|
+
u = res.local.new(remote)
|
45
|
+
u.id = id
|
46
|
+
end
|
41
47
|
if u.save
|
42
48
|
res.count = res.count + 1
|
43
49
|
else
|
@@ -23,15 +23,16 @@ class Ixtlan::Core::Heartbeat
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def reg
|
26
|
-
@reg ||=
|
26
|
+
@reg ||= {}
|
27
27
|
end
|
28
28
|
|
29
29
|
def register(local, remote)
|
30
|
-
reg
|
30
|
+
reg[local] = Resource.new(local, remote)
|
31
31
|
end
|
32
32
|
|
33
|
-
def beat
|
34
|
-
reg.
|
33
|
+
def beat(resource = nil)
|
34
|
+
resources = resource.nil? ? reg.values : [reg[resource]]
|
35
|
+
resources.each do |res|
|
35
36
|
last_update = res.local.maximum(:updated_at) || 2000.years.ago
|
36
37
|
last_update = last_update.strftime('%Y-%m-%d %H:%M:%S.') + ("%06d" % last_update.usec)
|
37
38
|
res.remote.get(:last_changes, :updated_at => last_update).each do |remote|
|