Skip to content

Commit

Permalink
Merge pull request #389 from tbrisker/auditedchanges
Browse files Browse the repository at this point in the history
Simplify audited_changes
  • Loading branch information
tbrisker authored Jan 1, 2018
2 parents e1dd759 + fdc4b7d commit 248acde
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions lib/audited/auditor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,11 @@ def rails_below?(rails_version)
private

def audited_changes
all_changes = respond_to?(:attributes_in_database) ? attributes_in_database : changed_attributes
collection =
if audited_options[:only]
all_changes.slice(*audited_columns)
else
all_changes.except(*non_audited_columns)
end

collection.inject({}) do |changes, (attr, old_value)|
changes[attr] = [old_value, self[attr]]
changes
all_changes = respond_to?(:changes_to_save) ? changes_to_save : changes
if audited_options[:only]
all_changes.slice(*audited_columns)
else
all_changes.except(*non_audited_columns)
end
end

Expand Down

0 comments on commit 248acde

Please sign in to comment.