lib/ixtlan/optimistic/stale_check.rb in ixtlan-optimistic-0.2.0 vs lib/ixtlan/optimistic/stale_check.rb in ixtlan-optimistic-0.2.1
- old
+ new
@@ -28,14 +28,17 @@
raise ObjectStaleException.new "no 'updated_at' given. could not find #{signature(*args)}."
end
end
def __check_stale( updated_at, result )
- if updated_at.is_a?( String )
+ if updated_at.is_a? String
updated_at = DateTime.parse( updated_at.sub(/[.][0-9]+/, '') )
end
+ if defined?( ActiveSupport ) && 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.new_offset(0).strftime("%Y:%m:%d %H:%M:%S")
+ 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.inspect} is stale for updated at #{updated_at}."
end
result
end