Module: LogBook::Plugin::InstanceMethods

Defined in:
lib/log_book/plugin.rb

Instance Method Summary collapse

Instance Method Details

#log_book_event_on_createObject



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

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

#log_book_event_on_destroyObject



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

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

#log_book_event_on_updateObject



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

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