Module: LogBook::Plugin::InstanceMethods

Defined in:
lib/log_book/plugin.rb

Instance Method Summary collapse

Instance Method Details

#log_book_event_on_createObject



27
28
29
# File 'lib/log_book/plugin.rb', line 27

def log_book_event_on_create
  LogBook.created(self.log_book_historian, self) if !self.log_book_mute
end

#log_book_event_on_destroyObject



41
42
43
# File 'lib/log_book/plugin.rb', line 41

def log_book_event_on_destroy
  LogBook.destroyed(self.log_book_historian, self) if !self.log_book_mute
end

#log_book_event_on_updateObject



31
32
33
34
35
36
37
38
39
# File 'lib/log_book/plugin.rb', line 31

def log_book_event_on_update
  # TODO: this line of code is duplicated
  if ActiveRecord::VERSION::STRING.to_f >= 5.1
    clean_changes = saved_changes.select { |k,v| !self.log_book_options[:ignore].include? k.to_sym }
  else
    clean_changes = changes.select { |k,v| !self.log_book_options[:ignore].include? k.to_sym }
  end
  LogBook.updated(self.log_book_historian, self) if !clean_changes.empty? and !self.log_book_mute
end