class Breathing::ChangeLog
Public Instance Methods
attributes_for_excel()
click to toggle source
# File lib/breathing/change_log.rb, line 37 def attributes_for_excel { 'change_logs.id' => id, 'created_at' => created_at.to_s(:db), 'table_name' => table_name, 'action' => action, 'id' => transaction_id, 'diff' => diff } end
changed_attribute_columns()
click to toggle source
# File lib/breathing/change_log.rb, line 5 def changed_attribute_columns before_data.each.with_object([]) do |(column, value), columns| columns << column if after_data[column] != value end end
data()
click to toggle source
# File lib/breathing/change_log.rb, line 16 def data action == 'DELETE' ? before_data : after_data end
data_attributes()
click to toggle source
# File lib/breathing/change_log.rb, line 20 def data_attributes data_column_names.each.with_object('change_logs.id' => id, 'change_logs.created_at' => created_at.to_s(:db), 'action' => action, 'id' => transaction_id) do |name, hash| hash[name] = data[name] end end
data_column_names()
click to toggle source
# File lib/breathing/change_log.rb, line 11 def data_column_names names = before_data.keys.present? ? before_data.keys : after_data.keys names.reject { |name| name == 'id' } end
diff()
click to toggle source
# File lib/breathing/change_log.rb, line 29 def diff return nil if action != 'UPDATE' changed_attribute_columns.map do |column_name| "#{column_name}: #{before_data[column_name]} -> #{after_data[column_name]}" end.join(" \n") end