7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/bushido/models.rb', line 7
def bushido_save
puts "what"
puts "new_record? #{self.new_record?}"
puts "self.id = #{self.id}"
puts "ido_id.nil? #{ido_id.nil?}"
puts "ido_version == self.class.find(self.id).ido_version ? #{ido_version == self.class.find(self.id).ido_version}" unless self.new_record?
if self.ido_id.nil? or (not self.new_record? and self.ido_version == self.class.find(self.id).ido_version)
puts "Local change, publishing to Bushido databus"
data = self.to_bushido
begin
response = Bushido::Data.publish(self.class.class_variable_get("@@bushi_model"), data)
rescue => e
puts e.inspect
return false
end
self.ido_version = response["ido_version"]
self.ido_id ||= response["ido_id"]
puts response.inspect
else
puts "Remote change, not publishing to Bushido databus"
end
return true
end
|