lib/tracer_client/changes.rb in tracer_client-0.1.3 vs lib/tracer_client/changes.rb in tracer_client-0.1.4
- old
+ new
@@ -16,11 +16,11 @@
%i(ignore skip only).each do |k|
changes_logging_options[k] =
[changes_logging_options[k]].flatten.compact.map { |attr| attr.is_a?(Hash) ? attr.stringify_keys : attr.to_s }
end
- options_on = Array(options[:on]) # so that a single symbol can be passed in without wrapping it in an `Array`
+ options_on = Array.wrap(options[:on]) # so that a single symbol can be passed in without wrapping it in an `Array`
after_create :log_create, :if => :log_changes? if options_on.empty? || options_on.include?(:create)
if options_on.empty? || options_on.include?(:update)
before_update :log_update, :if => :log_changes?
@@ -42,11 +42,11 @@
item_id: id,
item_type: self.class.base_class.name,
event: 'create',
changes: changes_for_tracing,
)
- rescue Exception => e
+ rescue => e
Log.exception_with_alert(e, 'Ошибка регистрации создания', 'log_changes create',
item_id: id,
item_type: self.class.base_class.name)
end
@@ -59,11 +59,11 @@
event: 'update',
object: object_attrs_for_tracing(item_before_change),
changes: changes_for_tracing,
)
end
- rescue Exception => e
+ rescue => e
Log.exception_with_alert(e, 'Ошибка регистрации изменения', 'log_changes update',
item_id: id,
item_type: self.class.base_class.name)
end
@@ -75,11 +75,11 @@
item_type: self.class.base_class.name,
event: 'destroy',
object: object_attrs_for_tracing(item_before_change),
)
end
- rescue Exception => e
+ rescue => e
Log.exception_with_alert(e, 'Ошибка регистрации удаления', 'log_changes destroy',
item_id: id,
item_type: self.class.base_class.name)
end
@@ -125,10 +125,10 @@
def item_before_change
previous = self.dup
# `dup` clears timestamps so we add them back.
all_timestamp_attributes.each do |column|
- previous[column] = send(column) if self.class.column_names.include?(column.to_s) and not send(column).nil?
+ previous[column] = send(column) if self.class.column_names.include?(column.to_s) and not try(column).nil?
end
previous.tap do |prev|
prev.id = id # `dup` clears the `id` so we add that back
changed_attributes.select { |k,v| self.class.column_names.include?(k) }.each { |attr, before| prev[attr] = before }
end