32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/ixtlan/optimistic/stale_check.rb', line 32
def __check_stale( updated_at, result )
if updated_at.is_a? String
updated_at = DateTime.parse( updated_at.sub(/[.][0-9]+/, '') )
end
if defined?( ActiveSupport::TimeWithZone ) && updated_at.is_a?( ActiveSupport::TimeWithZone )
updated_at = updated_at.to_datetime
end
updated_at = updated_at.new_offset(0)
if updated_at != result.updated_at && updated_at.strftime("%Y:%m:%d %H:%M:%S") != result.updated_at.strftime("%Y:%m:%d %H:%M:%S")
raise ObjectStaleException.new "#{result.model} with key [#{result.id}] was updated at #{result.updated_at} is newer than the given one which was updated at #{updated_at}."
end
result
end
|