lib/chrono_model/utilities.rb in chrono_model-1.2.2 vs lib/chrono_model/utilities.rb in chrono_model-2.0.0
- old
+ new
@@ -1,7 +1,8 @@
-module ChronoModel
+# frozen_string_literal: true
+module ChronoModel
module Utilities
# Amends the given history item setting a different period.
# Useful when migrating from legacy systems.
#
# To use it, extend AR::Base with ChronoModel::Utilities
@@ -9,11 +10,11 @@
# ActiveRecord::Base.instance_eval do
# extend ChronoModel::Utilities
# end
#
def amend_period!(hid, from, to)
- unless [from, to].any? {|ts| ts.respond_to?(:zone) && ts.zone == 'UTC'}
+ unless [from, to].any? { |ts| ts.respond_to?(:zone) && ts.zone == 'UTC' }
raise 'Can amend history only with UTC timestamps'
end
connection.execute %[
UPDATE #{quoted_table_name}
@@ -21,7 +22,6 @@
"recorded_at" = #{connection.quote(from)}
WHERE "hid" = #{hid.to_i}
]
end
end
-
end