Sha256: 496d4f739febe646868a28600a44e87abb6d427fe7fbb29366c734c6ce4c24e2
Contents?: true
Size: 818 Bytes
Versions: 3
Compression:
Stored size: 818 Bytes
Contents
module LogBook::Utils def self.pretty_changes(model) # TODO: this line of code is duplicated if ActiveRecord::VERSION::STRING.to_f >= 5.1 clean_changes = model.saved_changes.select { |k,v| !model.log_book_options[:ignore].include? k.to_sym } else clean_changes = model.changes.select { |k,v| !model.log_book_options[:ignore].include? k.to_sym } end result = clean_changes.map do |k,v| old_value = v[0] new_value = v[1] old_value = old_value.to_s( :localdb ) if old_value.instance_of? ActiveSupport::TimeWithZone new_value = new_value.to_s( :localdb ) if new_value.instance_of? ActiveSupport::TimeWithZone { "key" => k, "before" => old_value, "after" => new_value } end result end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
log_book-0.7.1 | lib/log_book/utils.rb |
log_book-0.6.3 | lib/log_book/utils.rb |
log_book-0.6.1 | lib/log_book/utils.rb |