module LogBook::Recorder::RecordingInstanceMethods
Public Instance Methods
non_recording_columns()
click to toggle source
# File lib/log_book/recorder.rb, line 45 def non_recording_columns self.class.non_recording_columns end
recording_attributes()
click to toggle source
# File lib/log_book/recorder.rb, line 41 def recording_attributes attributes.except(*non_recording_columns) end
recording_changes()
click to toggle source
# File lib/log_book/recorder.rb, line 25 def recording_changes @recording_changes ||= RecordingChanges.new(self) end
recording_key()
click to toggle source
# File lib/log_book/recorder.rb, line 49 def recording_key "#{self.class.table_name}_#{id}" end
recording_options()
click to toggle source
# File lib/log_book/recorder.rb, line 29 def recording_options self.class.recording_options end
save_with_recording()
click to toggle source
# File lib/log_book/recorder.rb, line 33 def save_with_recording with_recording { save } end
with_recording(&block)
click to toggle source
# File lib/log_book/recorder.rb, line 37 def with_recording(&block) self.class.with_recording(&block) end
Private Instance Methods
log_book_meta(_record)
click to toggle source
# File lib/log_book/recorder.rb, line 85 def log_book_meta(_record) raise NotImplementedError end
log_book_meta_info(record)
click to toggle source
# File lib/log_book/recorder.rb, line 75 def log_book_meta_info(record) meta_options = recording_options[:meta] case meta_options when NilClass then nil when Symbol then send(meta_options, record) when Proc then meta_options.call(self, record) when TrueClass then log_book_meta(record) end end
record_changes()
click to toggle source
# File lib/log_book/recorder.rb, line 55 def record_changes if recording_options[:only] recording_columns = self.class.recording_columns.map(&:name) saved_changes.slice(*recording_columns) else saved_changes.except(*non_recording_columns) end end
store_changes()
click to toggle source
# File lib/log_book/recorder.rb, line 64 def store_changes return unless LogBook.recording_enabled recording_changes.tap do |record| record.record_changes = record_changes record.meta = log_book_meta_info(record) if recording_options[:meta].present? end LogBook::Store.tree.add(recording_changes) end